title: ASP JMail 4.5 SMTP Authentication for Office365
body: <p>We have some old apps written in Classic ASP which send mail using JMail (w3JMail v 4.5). We are in the process of moving from a local Microsoft Exchange server to Office 365. We need these old apps to continue to work, using JMail to send e-mail.</p>
  
  <p>Our current ASP code (which references the Exchange server by IP):</p>
  
  <pre><code>Set objMail = Server.CreateObject("JMail.Message")
  objMail.MailServerUserName = "domain\username"
  objMail.MailServerPassWord = "password"
  objMail.ContentType = "text/plain"
  objMail.From = "name1@domain.co.uk"
  objMail.AddRecipient "name2@domain.co.uk"
  objMail.Subject = "Test"
  objMail.Body = "Test"
  objMail.Send("10.10.10.1")
  Set objMail = Nothing
  </code></pre>
  
  <p>This is the new version I have to try and use our Office 365 account:</p>
  
  <pre><code>Set objMail = Server.CreateObject("JMail.Message")
  objMail.Silent = True
  objMail.Logging = True
  objMail.MailServerUserName = "name1@domain.co.uk"
  objMail.MailServerPassword = "password"
  objMail.ContentType = "text/plain"
  objMail.From = "name1@domain.co.uk"
  objMail.AddRecipient "name2@domain.co.uk"
  objMail.Subject = "Test"
  objMail.Body = "Test"
  If objMail.Send("smtp.office365.com:587") Then
      Response.Write "Sent an e-mail..."
  Else
      Response.Write( "ErrorCode: " &amp; objMail.ErrorCode &amp; "&lt;br /&gt;" )
      Response.Write( "ErrorMessage: " &amp; objMail.ErrorMessage &amp; "&lt;br /&gt;" )
      Response.Write( "ErrorSource: " &amp; objMail.ErrorSource &amp; "&lt;br /&gt;&lt;br /&gt;" )
      Response.Write( "" &amp; objMail.Log &amp; "&lt;br /&gt;&lt;br /&gt;" )
  End If
  Set objMail = Nothing
  </code></pre>
  
  <p>I know that our username and password are correct, and that the host name is correct. </p>
  
  <p>This is taken from the log output:</p>
  
  <pre><code>AUTH LOGIN
   &lt;- 504 5.7.4 Unrecognized authentication type
  Authentication failed.
    smtp.office365.com:587 failed..
    No socket for server. ConnectToServer()
  </code></pre>
  
  <p>How can we set the authentication type using JMail..?</p>