Sonu Singh

Sonu Singh

  • NA
  • 21
  • 978

Use c# in asp.net to perform sending e-mail

Feb 13 2014 2:35 PM
using System.Net; using System.Net.Mail;  var fromAddress = new MailAddress("[email protected]", "From Name"); var toAddress = new MailAddress("[email protected]", "To Name"); const string fromPassword = "fromPassword"; const string subject = "Subject"; const string body = "Body";  var smtp = new SmtpClient            {                Host = "smtp.gmail.com",                Port = 587,                EnableSsl = true,                DeliveryMethod = SmtpDeliveryMethod.Network,                UseDefaultCredentials = false,                Credentials = new NetworkCredential(fromAddress.Address, fromPassword)            }; using (var message = new MailMessage(fromAddress, toAddress)                      {                          Subject = subject,                          Body = body                      }) {     smtp.Send(message); }

Answers (1)