How to send email by ASP.Net C#

MailMessage msgMail = new MailMessage();
msgMail.To = txtTo.Text;
msgMail.From = txtFrom.Text;
msgMail.Cc = txtCc.Text;
msgMail.Subject = "Test Email";
msgMail.Body = txtName.Text + ", " +
txtComments.Text;
msgMail.Priority = MailPriority.High;

//SmtpMail.SmtpServer = "localhost";
try{
SmtpMail.Send(msgMail);
Response.Write("Your Email has been sent sucessfully -
Thank You");
}
catch (Exception exc){
Response.Write("Send failure: " + exc.ToString());
}


Comments

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:
    Email: