3
Answers

Try to send Image attached Email

Rahul Kumar

Rahul Kumar

5y
508
1
MailMessage mail = new MailMessage();
mail.From = new MailAddress("[email protected]");
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)