Send E-Mail from .NET application
.NET 2.0 has included System.Net.Mail code namespace for supporting email programming with .NET
Following is the code snippets for how to send mail from .NET application.
Following is the code snippets for how to send mail from .NET application.
MailMessage mail = new MailMessage();
mail.To.Add("email1@email1.com");
mail.To.Add("email2@email2.com");
// you can add even add more to address in the same way.
mail.From = new MailAddress("from email address");
// enter the email address. this address will show in the from field of recipient.
mail.Subject = "Email using .NET";
string Body = "Hi, this mail is to test sending mail";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtpserveraddress"; //Or Your SMTP Server Address
// enter you smtp server name.
smtp.Credentials = new System.Net.NetworkCredential("smtp username", "smtp password");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
// if required
smtp.Send(mail);