Code:
public void SendEmailByGmail()
{
MailMessage mail = new MailMessage();
mail.To.Add("your@gmail.com");
mail.To.Add("recever@yahoo.com");
mail.From = new MailAddress("your@gmail.com");
mail.Subject = "Email using Gmail";
string Body = "Hi, this mail is to test sending mail" + "using Gmail in ASP.NET";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.NetNetworkCredential("YourUserName@gmail.com", "YourGmailPassword");//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
}
No comments:
Post a Comment