title: Error "Client was not authenticated to send anonymous mail"
body: <p>i try to send an email with this code...but i have this error :"Client was not authenticated to send anonymous mail during MAIL FROM"</p>
  
  <p>code:</p>
  
  <pre><code>var smtpClient = new SmtpClient()
          {
              Host = "smtp.office365.com",
              Port = 25, //587
              UseDefaultCredentials = false,
              EnableSsl = true
          };
          smtpClient.UseDefaultCredentials = false;
          smtpClient.DeliveryMethod= System.Net.Mail.SmtpDeliveryMethod.Network; 
          smtpClient.Credentials = new NetworkCredential("{mail}", "{password}","{domain}");
  
          var message = new MailMessage
          {
              From = new MailAddress("{mail}","{display name}",System.Text.Encoding.UTF8),
  
              Subject = "Test mail",
              IsBodyHtml = false
          };
          message.To.Add("{mail}");
  
          message.Body = "This is a test mail. ";
          try{
              smtpClient.Send(message);
  
          }
          catch (Exception ex)
          {
              throw new Exception(ex.Message, ex);
          }
  </code></pre>
  
  <p>thanks</p>