System.Net.Mail.SmtpException:操作已超时

时间:2018-06-14 08:40:05

标签: c# email smtp office365

我使用以下代码使用Office 365发送电子邮件

MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress("Test@yahoo.com"));
msg.From = new MailAddress("ouremailAddress@ourdomain.com");
msg.Subject = subject;
msg.Body = EmailBody;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Host = "smtp.office365.com";
client.Credentials = new System.Net.NetworkCredential("USername", "Password");
client.Port = 587;
client.EnableSsl = true;
client.Send(msg);

这段代码工作但每隔几天就会出现一次错误 System.Net.Mail.SmtpException:操作已超时。在System.Net.Mail.SmtpClient.Send(MailMessage消息)

我知道这个问题不止一次被问过,但他们很老了 SmtpException - The operation has timed out

System.Net.Mail.SmtpException: The operation has timed out. error in asp.net send mail code using godaddy hosting

但是有人说它是SSL和端口问题,我已经尝试过与其他端口相同但仍然相同。所以任何帮助都会很棒

更多信息 当我做调试时,我没有收到此错误 但是在Try {}和Catch {}中发送电子邮件 如果有错误,应用程序会发送电子邮件给我,这就是我知道存在问题的方法

0 个答案:

没有答案