我在Exchange Online服务上拥有一个邮件帐户。现在我正在尝试测试是否能够通过C#应用程序向客户(在各种域和Microsoft Office 365上)发送电子邮件。
我尝试实现以下代码,但是我遇到了错误
"The remote certificate is invalid according to the validation procedure."
MailMessage mail = null;
mail = new MailMessage();
string[] strToList = "abc@gmail.com"
foreach (string strID in strToList)
{
if (strID != null)
{
mail.To.Add(new MailAddress(strID));
}
}
mail.From = "demo@onmicrosoft.com";
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("demo@onmicrosoft.com", "mypassword");
client.Credentials = cred;
client.Send(mail);
请告诉我是否有做错什么。非常感谢。