title: Send SMTP email testing Microsoft Office 365 in .net
body: <p>i have a mail account on the Exchange Online service. Now i'm trying to test if i am able to send mails to customers ( on varoius domains and on Microsoft Office 365) through c# application</p>
  
  <p>I tried implementing the below code but i am getting the error </p>
  
  <blockquote>
    <p><em>"The remote certificate is invalid according to the validation
    procedure."</em></p>
  </blockquote>
  
  <pre><code>MailMessage mail = null;                
  mail = new MailMessage();
  
  string[] strToList = "abc@gmail.com"              
  foreach (string strID in strToList)
  {
      if (strID != null)
      {
          mail.To.Add(new MailAddress(strID));
      }
  }
  
  mail.From = "demo@onmicrosoft.com";
  mail.Subject = "testing"
  mail.IsBodyHtml = true;
  mail.Body = "mail body";
  
  SmtpClient client = new SmtpClient("smtp.outlook.office365.com");
  client.Port = 587;
  client.EnableSsl = true;
  client.UseDefaultCredentials = false;
  NetworkCredential cred = new System.Net.NetworkCredential("demo@onmicrosoft.com", "mypassword");
  client.Credentials = cred;
  client.Send(mail);
  </code></pre>
  
  <p>Please advice if i am doing anything wrong.
  Thanks a lot in advance.</p>