title: System.Net.Mail.SmtpException: The operation has timed out
body: <p>I am using the code below to send email using office 365</p>
  <pre><code>MailMessage msg = new MailMessage();
  msg.To.Add(new MailAddress(&quot;Test@yahoo.com&quot;));
  msg.From = new MailAddress(&quot;ouremailAddress@ourdomain.com&quot;);
  msg.Subject = subject;
  msg.Body = EmailBody;
  msg.IsBodyHtml = true;
  SmtpClient client = new SmtpClient();
  client.Host = &quot;smtp.office365.com&quot;;
  client.Credentials = new System.Net.NetworkCredential(&quot;USername&quot;, &quot;Password&quot;);
  client.Port = 587;
  client.EnableSsl = true;
  client.Send(msg);
  </code></pre>
  <p>this code work but once every few days i get an error of
  System.Net.Mail.SmtpException: The operation has timed out. at System.Net.Mail.SmtpClient.Send(MailMessage message)</p>
  <p>i know there the question has been asked more than once, but they are very old Like
  <a href="https://stackoverflow.com/questions/10743548/smtpexception-the-operation-has-timed-out">SmtpException - The operation has timed out</a></p>
  <p>or</p>
  <p><a href="https://stackoverflow.com/questions/14828304/system-net-mail-smtpexception-the-operation-has-timed-out-error-in-asp-net-sen">System.Net.Mail.SmtpException: The operation has timed out. error in asp.net send mail code using godaddy hosting</a></p>
  <p>but some say that it is SSL and port issue, i have tried it with other port and still the same. so any help would be great</p>
  <hr />
  <p><strong>More Information</strong>
  when i do the debugging i don't get this error
  but sending an email is with in Try {} and Catch {}
  and if there is error the application send an email to me that is how i know there is issue</p>