title: Asp.net MVC5 with SMTP Office365 Exception at version 4.5.2, the code works well at version 4.8
body: <p><a href="https://i.stack.imgur.com/Nmuqx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nmuqx.png" alt="enter image description here" /></a></p>
  <p>I have an ASP.net MVC5 app that uses Office365 to send emails to subscribers the runtime version is 4.5.2</p>
  <p>when I tried it in a new project with runtime version 4.8, it worked fine with no Errors, how to migrate this code to older runtime versions</p>
  <pre><code>public string SendEmail()
  {
      MailAddress toAddress = new MailAddress(&quot;test2@test.com&quot;, &quot;Test&quot;);
      const string subject = &quot;Outlook Test&quot;;
      const string HtmlBody = &quot;This is our outlook Test&quot;;
      SendConEmail(toAddress, subject, HtmlBody);
       return &quot;Email successfully Sent&quot;;
  }
  
  public static void SendConEmail(MailAddress toAddress, string subject, string HtmlBody)
  {
      MailAddress fromAddress = new MailAddress(&quot;test@test.com&quot;, &quot;Test&quot;);
      const string fromPassword = &quot;PAssword Here&quot;;
      var smtp = new SmtpClient
      {
          // Host = &quot;smtp-mail.outlook.com&quot;,
          Host = &quot;smtp.office365.com&quot;,
          Port = 587,
          EnableSsl = true,
          DeliveryMethod = SmtpDeliveryMethod.Network,
          UseDefaultCredentials = false,
          Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
      };
      try
      {
          using (var message = new MailMessage(fromAddress, toAddress)
          {
              Subject = subject,
              Body = HtmlBody,
              IsBodyHtml = true
          })
          {
              smtp.Send(message);
          }
      }
      catch (Exception ex)
      {
         Console.WriteLine(ex);
      }
  }
  </code></pre>