How to send emails through Asp.Net?

protected void Button1_Click(object sender, EventArgs e)
MailMessage mail = new MailMessage();
mail.From = new MailAddress("");
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 = ""; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;



No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: