send email

send email via C# .Net


System.Net.Mail.
MailMessage email = new System.Net.Mail.MailMessage();

email.To.Add("xyz@gmail.com"); //reciever email

email.From = new System.Net.Mail.MailAddress("myEmail@gmail.com", "your Name"); //sender email & display Name

email.Subject = "My First C# mail"; //message subject

email.Body = "i am testing my first e-mail program."; //message body

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com"); //email server name

smtp.EnableSsl = true; //set false if your email server not using Ssl.

smtp.Credentials = new System.Net.NetworkCredential("myEmail@gmail.com", "password");//sender email & Password

smtp.Send(email);

by: Pankaj Sharma