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. :P

Related topics:
Email chinese character – C# source code

Random Posts