title: Send mail with CDO through Google Apps gives transport error: CDO.Message.1 error '80040213'
body: <p>I'm trying to send an contact enquiry email from a legacy classic asp script using a Google Apps account as the SMTP server. The code I have to test this is as follows:</p>
  
  <pre><code>Dim ObjSendMail
  Set ObjSendMail = CreateObject("CDO.Message") 
  
  'This section provides the configuration information for the remote SMTP server.
  ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
  ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.thedomain.com"
  ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 ' or 587
  ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
  ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
  
  ' Google apps mail servers require outgoing authentication. Use a valid email address and password registered with Google Apps.
  ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
  ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="info@thedomain.com" 'your Google apps mailbox address
  ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="password" 'Google apps password for that mailbox
  
  ObjSendMail.Configuration.Fields.Update
  
  ObjSendMail.To = "me@mydomain.net"
  ObjSendMail.Subject = "this is the subject"
  ObjSendMail.From = "info@thedomain.com"
  
  ' we are sending a text email.. simply switch the comments around to send an html email instead
  'ObjSendMail.HTMLBody = "this is the body"
  ObjSendMail.TextBody = "this is the body"
  
  ObjSendMail.Send
  Set ObjSendMail = Nothing 
  </code></pre>
  
  <p>I've tried both port numbers 465 and 587.  I've tried mail.thedomain.com and smtp.thedomain.com and mail.gmail.com and smtp.gmail.com as the SMTP server, but nothing works.  I've logged into the Google Apps account with the email address and password in the script, so those details are definitely correct.</p>
  
  <p>All I can get though is the following error:</p>
  
  <pre><code>CDO.Message.1 error '80040213'
  
  The transport failed to connect to the server.
  
  /_test-email.asp, line 46 
  </code></pre>
  
  <p>(line 46 is where it says ObjSendMail.Send)</p>
  
  <p>Can anyone see what might be wrong?</p>
  
  <p>Thanks folks!</p>