DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Send Email Using C#
// send email using c#.net
private void SendYourEmailFunction()
{
MailMessage myMsg= new MailMessage();
myMsg.To.Add("destination@test.com");
myMsg.Bcc.Add("mymail@test.com");
myMsg.Subject = "test mail";
myMsg.From = new MailAddress("test@test.com");
myMsg.Body = HttpUtility.HtmlDecode(messageContent); html format
myMsg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
System.Net.NetworkCredential AuthInfo = new System.Net.NetworkCredential("mymail@test.com", "mypassword");
smtp.Host = strSMTPServer; // smtp.yourdomain.com
smtp.UseDefaultCredentials = false;
smtp.Credentials = AuthInfo;
smtp.Timeout = 20;
smtp.Port = 25;
smtp.EnableSsl = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(myMsg);
}




