Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have implemented sending mails through SMTP in my asp.net application.
I want to attach a file using hyperlink button.
How to do that?

Thanks
Posted

You will find the answer in my past post: Sending HTML attachment with images[^].

The term "attachment" is very misleading. The files are never "attached" to any mail message. A mail message can be multipart, and some part can be a file coded as base64 text. It has its own part headers, with content type showing how to process the file, and context disposition suggesting the mail viewer application what to do with the part. My past answer just explains how to reference a part in another part, as HTML anchor.

See also: http://en.wikipedia.org/wiki/MIME[^].

—SA
 
Share this answer
 
v2
use the below code:

System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("C:\mail_attach.jpg");
mail.Attachments.Add(attachment);
 
Share this answer
 

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