title: Office 365 SMTP starts firing net_io_connectionclosed
body: <p>A while ago I've configured my ASP.NET C# project to send e-mail via Office 365, but last week it's starting to throw a lot of exceptions.</p>
  
  <pre><code>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&amp; response) 
  at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException&amp; exception) 
  at System.Net.Mail.SmtpClient.Send(MailMessage message)
  </code></pre>
  
  <p>How can I prevent this from happening?</p>
  
  <pre><code>  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();
  </code></pre>
  
  <p>The exceptions seems to be thrown on the <strong>Dispose</strong>.</p>