对于仅发送邮件,您可以像这样使用 System.Net.Mail:
var mailMessage = new MailMessage();
mailMessage.To.Add(new MailAddress(RECEIVER_MAIL_ADDRESS));
mailMessage.From = new MailAddress(SENDER_MAIL_ADDRESS, SENDER_NAME);
mailMessage.Subject = SUBJECT;
mailMessage.Body = BODY;
mailMessage.IsBodyHtml = true;
using (var smtp = new SmtpClient("smtp.office365.com", 587))
{
var credential = new NetworkCredential
{
UserName = USERNAME,
Password = PASSWORD,
Domain = DOMAIN_OPTIONAL
};
smtp.Credentials = credential;
smtp.EnableSsl = true;
smtp.TargetName = "";
await smtp.SendMailAsync(mailMessage);
}