title: How to send e-mail through VBA without Outlook
body: <p>I'm trying to send email through SMTP in VBA, but is returning error.</p>
  <pre><code>Dim CDOmsg As CDO.Message
  Set CDOmsg = New CDO.Message
  
  With CDOmsg.Configuration.Fields
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpusessl&quot;) = True
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpauthenticate&quot;) = 1
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpserver&quot;) = &quot;smtp.gmail.com&quot;
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/sendusername&quot;) = &quot;myemail@gmail.com&quot;
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/sendpassword&quot;) = &quot;mypass&quot;
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/smptserverport&quot;) = 465
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/sendusing&quot;) = 2 'NTLM method
      .Item(&quot;http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout&quot;) = 60
      .Update
  End With
  ' build email parts
  With CDOmsg
      .Subject = &quot;the email subject&quot;
      .From = &quot;myemail@gmail.com&quot;
      .To = &quot;mailto@gmail.com&quot;
      .CC = &quot;&quot;
      .BCC = &quot;&quot;
      .TextBody = &quot;the full message body goes here. you may want to create a variable to hold the text&quot;
  End With
  CDOmsg.Send
  Set CDOmsg = Nothing
  </code></pre>
  <p>The error is on CDOmsg.Send. I've tried to send with Gmail and Yahoo Mail, but I get this same error.</p>
  <blockquote>
  <p>Error code: -2147220973(80040213)</p>
  <p>Error description: The transport failed to connect to the server</p>
  </blockquote>