2015-02-06 83 views
4

前一段時間,我配置了我的ASP.NET C#項目以通過Office 365發送電子郵件,但上週它開始拋出許多異常。Office 365 SMTP開始發射net_io_connectionclosed

System.IO.IOException: Unable to read data from the transport connection: net_io_connectionclosed. 
at System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine) 
at System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) 
at System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) 
at System.Net.Mail.CheckCommand.Send(SmtpConnection conn, String& response) 
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception) 
at System.Net.Mail.SmtpClient.Send(MailMessage message) 

我該如何防止這種情況發生?

MailMessage message = new MailMessage(System.Configuration.ConfigurationManager.AppSettings["smtpfrom"], email, strOnderwerp, strBody); 
      message.Priority = MailPriority.Normal; 
      message.IsBodyHtml = true; 
      SmtpClient client = new SmtpClient(System.Configuration.ConfigurationManager.AppSettings["smtpserver"], Convert.ToInt32((System.Configuration.ConfigurationManager.AppSettings["smtpport"]))); 

      client.EnableSsl = Boolean.Parse(System.Configuration.ConfigurationManager.AppSettings["smtpssl"]); ; 
      client.Credentials = new System.Net.NetworkCredential(System.Configuration.ConfigurationManager.AppSettings["smtpuser"], System.Configuration.ConfigurationManager.AppSettings["smtppass"]); 

      client.Send(message); 
      client.Dispose(); 

的例外似乎是在處置拋出。

回答

5

同樣的問題從2月8日我公司開始。問題會出現並且沒有模式。

我相信解決了這個問題是對SMTP服務器地址的改變。

我們原來的SMTP服務器地址是podxxxxx.outlook.com,並且大部分時間仍然有效。我在我們的門戶中檢查了當前的O365 SMTP服務器地址,它應該是smtp.office365.com。

我改變了我的配置,指向這個新地址,問題似乎已消失。我的日誌顯示更改後的最近24小時內沒有錯誤。

如果錯誤再次發生,我會更新它。

+0

取代smtp.office365.com pod51014.outlook.com - 希望最好。 – Rob 2015-02-15 21:42:43