Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to attach multiple Image files to mail from file upload control.
Its being attached but when I am trying to open those image its not opening.

below codes for more clarity

C#
 using (MailMessage mm = new MailMessage(senderId, receiverId))
         {
                   
            foreach (HttpPostedFile uploadedFile in imgUpload.PostedFiles)
             {
               string FileName = Path.GetFileName(uploadedFile.FileName);
               mm.Attachments.Add(new Attachment(uploadedFile.InputStream, FileName));
             }
}



where imgUpload= file upload control with AllowMultiple properties "true"

Thanks In Advance

What I have tried:

using (MailMessage mm = new MailMessage(senderId, receiverId))
{

foreach (HttpPostedFile uploadedFile in imgUpload.PostedFiles)
{
string FileName = Path.GetFileName(uploadedFile.FileName);
mm.Attachments.Add(new Attachment(uploadedFile.InputStream, FileName));
}
}
Posted
Updated 3-Aug-16 4:44am

1 solution

 
Share this answer
 
Comments
dibyaaryan007 4-Aug-16 1:13am    
Thanks a lot Deepanker ! its working fine :)
deepankarbhatnagar 5-Aug-16 9:44am    
your welcome

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900