How to send email from C# windows application

  • Home
  • Blog
  • 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);