how to send email with attachmenet in asp.net

// to send email with asp.net
     System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage();
     msg.From= "Sanjiv_kumar_singh@yahoo.com";
   
     msg.To="Sanjiv_kumar_singh@hotmail.com";

     

     msg.Subject = "Welcome";
     msg.Body = "";
     msg.Priority =System.Web.Mail.MailPriority.High;
     msg.BodyFormat = System.Web.Mail.MailFormat.Html;
     System.Web.Mail.MailAttachment myAttachment = new  System.Web.Mail.MailAttachment("c:\\abc.txt");
     SmtpMail.SmtpServer.Insert ("localserver");
     msg.Attachments.Add(myAttachment);
     System.Web.Mail.SmtpMail.Send(msg);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s