title: Send SMTP email using System.Net.Mail via Exchange Online (Office 365)
body: <p>We are testing the new Office 365 beta, and i have a mail account on the Exchange Online service. Now I'm trying to connect a LOB application that can send smtp emails from my test account.</p>
  
  <p>However the Exchange 365 platform requires TLS encryption on port 587, and there is a 'feature' of <code>System.Net.Mail</code> that does not permit Implicit SSL encryption. </p>
  
  <p>Has anyone managed to get C# sending mails via this platform?</p>
  
  <p>I have the following basic code that should send the mail - any advice would be appreciated.</p>
  
  <pre><code>SmtpClient server = new SmtpClient("ServerAddress");
  server.Port = 587;
  server.EnableSsl = true;
  server.Credentials = new System.Net.NetworkCredential("username@mydomain.com", "password");
  server.Timeout = 5000;
  server.UseDefaultCredentials = false;
  
  MailMessage mail = new MailMessage();
  mail.From = new MailAddress("recipent@anyaddress");
  mail.To.Add("username@mydomain.com");
  mail.Subject = "test out message sending";
  mail.Body = "this is my message body";
  mail.IsBodyHtml = true;
  
  server.Send(mail);
  </code></pre>