Rahul Kumar

Rahul Kumar

  • 1.9k
  • 62
  • 2.7k

Try to send Image attached Email

Jan 20 2020 1:42 PM
MailMessage mail = new MailMessage();
mail.From = new MailAddress("....@gmail.com");
mail.Subject = "Weekend Plans";
foreach(var image in productImage)
{
Attachment attachment = new Attachment(image.Image);
attachment.TransferEncoding = TransferEncoding.Base64;
mail.Body = image.Comments;
mail.Attachments.Add(attachment);
 
Getting exception.
 
System.IO.PathTooLongException: 'The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters
 
How to handle exception?
 

Answers (3)