WebMail

try {
      WebMail.SmtpServer = "smtp.example.com";
     WebMail.SmtpPort = 587;
     WebMail.EnableSsl = true;
     WebMail.UserName = "mySmtpUsername";
     WebMail.Password = "mySmtpPassword";
     WebMail.From = "rsvps@example.com";
     WebMail.Send("party-host@example.com", "RSVP Notification",
     Model.Name + " is " + ((Model.WillAttend ?? false) ? "" :
     "not")
     + "attending");
} catch (Exception) {
     @:<b>Sorry - we couldn't send the email to confirm your RSVP.
     </b>
}
原文地址:https://www.cnblogs.com/dotnetmvc/p/3797000.html