var message = new MimeMessage(); //發送方 message.From.Add(new MailboxAddress("liyy", "xxxxx.com")); //接受方 message.To.Add(new MailboxAddress("Mrs. li", " ...
var message = new MimeMessage();
//發送方
message.From.Add(new MailboxAddress("liyy", "xxxxx.com"));
//接受方
message.To.Add(new MailboxAddress("Mrs. li", "xxxxx.com"));
//標題
message.Subject = "周末去哪嗨?";
//文字內容
message.Body = new TextPart("plain") { Text = "上海一日游" };
//開始發送
using (var client = new MailKit.Net.Smtp.SmtpClient())
{
client.ServerCertificateValidationCallback = (s, c, h, e) => true; client.Connect("smtp.live.com", 465, true); client.AuthenticationMechanisms.Remove("XOAUTH2"); client.Authenticate("發送方郵箱", "發送方郵箱Smtp授權碼"); client.Send(message);
client.Disconnect(true);
}