我在Exchange Online服務上有一個郵件帳戶。現在,我想測試,如果我能夠通過C#應用程序發送郵件給客戶(在varoius域和微軟的Office 365)在.net中發送測試Microsoft Office 365的SMTP電子郵件
我試圖執行下面的代碼,但我得到的錯誤
「根據驗證 過程,遠程證書無效。」
MailMessage mail = null;
mail = new MailMessage();
string[] strToList = "[email protected]"
foreach (string strID in strToList)
{
if (strID != null)
{
mail.To.Add(new MailAddress(strID));
}
}
mail.From = "[email protected]";
mail.Subject = "testing"
mail.IsBodyHtml = true;
mail.Body = "mail body";
SmtpClient client = new SmtpClient("smtp.outlook.office365.com");
client.Port = 587;
client.EnableSsl = true;
client.UseDefaultCredentials = false;
NetworkCredential cred = new System.Net.NetworkCredential("[email protected]", "mypassword");
client.Credentials = cred;
client.Send(mail);
請指教,如果我做錯了什麼。 非常感謝。
[發送使用Smtp.mail.microsoftonline.com電子郵件]的可能重複(http://stackoverflow.com/questions/6656039/sending-email-using-smtp-mail-microsoftonline-com) – bubbassauro 2013-08-05 16:16:35
HTTP ://www.softdeveloperszone.com/2013/04/send-email-through-office-365-outlook.html。在這一個有一個裂縫。爲我工作 – chamara 2016-11-13 09:04:55