How do I send an attachment in an email?
The following code shows how to add an attachment to an email.
Using System.IO;
Using System.Web.Mail;
MailAttachment ma=new MailAttachment("c:\sample.txt");
MailMessage mm=new MailMessage();
mm.To ="xyz@programmersheaven.com";
mm.From="abc@yahoo.com";
mm.Body ="Attachment";
mm.Subject="Check out the attached text file";
mm.Attachments.Add(ma);
SmtpMail.SmtpServer="mail.programmersheaven.com";
SmtpMail.Send(mm);
Written by Sandeep Mogulla, Webmaster at www.startvbdotnet.com
Index
Sponsored links
Check For Updates
Easily add update features to your applications. A complete .Net updating solution.
Easily add update features to your applications. A complete .Net updating solution.
Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Villanova University Six Sigma & IT Certificate Programs
100% Online programs in Six Sigma, IS Security, CISSP Prep, Business Analysis, Proj. Mgmt. and more!
100% Online programs in Six Sigma, IS Security, CISSP Prep, Business Analysis, Proj. Mgmt. and more!
.Net Localization in three simple steps (WYSIWYG)
Localize .Net, C#/C/C++ & Delphi apps visually. HTML, HTML Help, XML & databases. Try Sisulizer now!
Localize .Net, C#/C/C++ & Delphi apps visually. HTML, HTML Help, XML & databases. Try Sisulizer now!
