Thursday, September 22, 2011

Send Email messages in .Net

The following piece of code explains how to send email messages in .net framework. To do this you need following namespaces.

using System.Net.Mail;

using System.Net;

The following C# coding help to send emails:

private void SendEmail()


MailMessage mail = new MailMessage(); //Create MailMessage object

mail.From=new MailAddress(""); //set sender mail address

mail.To.Add(""); //add set of recipients

mail.Subject = "Subject"; //Subject

mail.Body = "Hi, Im ... Testing NTB mail..."; //Body

var client = new SmtpClient("", 587) //Set email client, email port


Credentials=new NetworkCredential("", "xxxxxxx"), EnableSsl=true

}; //Senders username, password





No comments:

Post a Comment