public static void SendEmail(StringBuilder sb) {
string mailbody = string.Empty;
MailMessage mail = new MailMessage();
SmtpClient smtpServer = new SmtpClient("aaaaa.com");
smtpServer.Credentials = new System.Net.NetworkCredential("username", "pwd");
//smtpServer.Port = 587;
mail.IsBodyHtml = true;
smtpServer.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
mail.BodyEncoding = System.Text.Encoding.UTF8;
smtpServer.UseDefaultCredentials = true;
smtpServer.EnableSsl = true;
mail.From = new MailAddress("bbbb.com");
mail.To.Add("ccccc.com");
mail.Subject = string.Format("test");
mailbody = sb.ToString();
mail.Body = mailbody;
smtpServer.Send(mail);
//每当我收到此错误消息以及如何处理此错误消息时,是否会绕过公司中的SSL违反安全性?请提供处理此代码和发送电子邮件的最佳方法。
}
最佳答案
尝试Unexpected “ The remote certificate is invalid according to the validation procedure.”
...告诉StmpClient忽略安全性
client.EnableSsl = true;