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();
的例外似乎是在處置拋出。
取代smtp.office365.com pod51014.outlook.com - 希望最好。 – Rob 2015-02-15 21:42:43