title: CDO.Message Email from Office 365 Account in VBA
body: <p>I'm trying to send an email from an account on Office 355 using CDO.message in VBA to automate some email tasks in Microsoft Access.</p>
  <p>The code is from <a href="https://www.tachytelic.net/2018/12/email-vbscript-vba-office-365/" rel="nofollow noreferrer">this</a> source.</p>
  <p>I get</p>
  <blockquote>
  <p>&quot;The transport failed to connect to the server&quot;</p>
  </blockquote>
  <p>From my research, it seems to be an issue with TLS authentication.</p>
  <pre class="lang-vb prettyprint-override"><code>Dim objMessage, objConfig, fields
  Set objMessage = New CDO.message
  Set objConfig = New CDO.Configuration
  Set fields = objConfig.fields
  With fields
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/sendusing&quot;) = 2
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpserver&quot;) = &quot;smtp.office365.com&quot;
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpserverport&quot;) = 25 '465
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpauthenticate&quot;) = 1
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/sendusername&quot;) = &quot;noreply@domain.ca&quot;
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/sendpassword&quot;) = &quot;passowrd&quot;
      '.Item(&quot;http://schemas.microsoft.com/cdo/configuration/sendtls&quot;) = True
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpusessl&quot;) = True
      .Update
  End With
  Set objMessage.Configuration = objConfig
      
  With objMessage
      .subject = &quot;Test Message&quot;
      .From = &quot;noreply@domain.ca&quot;
      .To = &quot;noreply@domain.ca&quot;
      .HTMLBody = &quot;Test Message&quot;
  End With
  objMessage.Send
  </code></pre>
  <p>EDIT: The email needs to be sent from the same email address no matter the user, and thus, I don't believe using Outlook will work.</p>
  <p>EDIT 2: It seems to be that ports 25 and 465 are blocked by my ISP. Using telnet I was able to get a response from port 587, however, I get the same error as before (except this time I get it immediately instead of after a long delay). Likely due to lack of TLS authentication.</p>