title: Use CDO Send Emails in Excel VBA Not Working
body: <p>I am trying to send email within Excel VBA. Based on my research on Internet, I enabled <code>Microsoft CDO for Windows 2000 Library</code> and composed my VBA codes as below:</p>
  
  <pre><code>Sub SendCDOMail()
      Dim objCDOMsg As Object
  
      Set objCDOMsg = CreateObject("CDO.Message")
  
      'CDO Configuration
      With objCDOMsg.Configuration.Fields
          '
          .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
          'Server port (typically 25, 587)
          .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
          'SMTP server IP or Name
          .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
          'Type of authentication, NONE, Basic (Base64 encoded), NTLM
          .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
          'SMTP Account User ID
          .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxx@bbbb.com"
          'SMTP Account Password
          .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxxx"
          'Use SSL for the connection (False or True)
          .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
          .Update
      End With
  
      'CDO Message
      objCDOMsg.Subject = "TEST Subject"
      objCDOMsg.From = "xx@xx.com"
      objCDOMsg.To = "xx@xx.com"
      objCDOMsg.TextBody = "TEST Body"
  
      objCDOMsg.Send
  
  End Sub
  </code></pre>
  
  <p>However, I received the error saying:</p>
  
  <pre><code>The server rejected the sender address. The server response was: 530.5.7.57 SMTP;
  Client was not authenticated to send anonymous mail during MAIL FROM
  </code></pre>
  
  <p>I also tried the same configurations using PowerShell and it worked (smtpserver, username, password, server port...).
  I don't know where it might go wrong.</p>