Below is the source code that will send email with attachment.
using System.Net.Mail;
MailMessage oMsg = new MailMessage();
oMsg.From = new MailAddress(”Email”, “Name”);
oMsg.To.Add(new MailAddress(”Email”,”Name”));
oMsg.Subject = “subject”;
oMsg.Body = “Mail contain”;
Attachment data = new Attachment(”File1″);
oMsg.Attachments.Add(data);
SmtpClient c = new SmtpClient(”SMTP”);
c.Send(oMsg);
oMsg.Dispose();
I have been facing problem with cannot delete my attachment from source. After troubleshooting, I found out that I forgot to put oMsg.Dispose(). Make sure you do so. ![]()
Related topics:
Email chinese character - C# source code
One Response
Email chinese character - C# source code by Jayce Ooi’s Paradise
May 21st, 2007 at 2:50 pm
1[…] Related topics: Send email with attachment c# source code […]
RSS feed for comments on this post · TrackBack URI
Leave a reply