Friday, June 8, 2007

How to send email from C# windows application

First find the System.Web.dll in your computer drive where .NET Framework installed

Then add a reference to that dll in your C# windows application.

then write following code to send email....

string smtpServer;
smtpServer= "127.0.0.1";
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage();
msg.From = "From Email Address";
msg.To = "To Email Address";
msg.Body = "Body here";
System.Web.Mail.MailAttachment attachFile = new System.Web.Mail.MailAttachment("Filepath");
System.Web.Mail.SmtpMail.SmtpServer = smtpServer; System.Web.Mail.SmtpMail.Send(msg);
Share:

1 comment:

  1. Got this error:

    The server rejected the sender address. The server response was: 530 5.7.0 Must issue a STARTTLS command first. z4sm18664799ibg.13

    Any suggestions?

    ReplyDelete

Your feedback is very important to me. Please provide your feedback via putting comments.

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My You tube channel- Please Subscribe
Youtube Video Playlist
My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews