Solved

Runtime Error -2147220973 sending email from vba Access 2010 using CDO

Posted on 2014-01-25
5
6,130 Views
Last Modified: 2014-01-26
Hi,

I am attempting to use the following code to send emails from my Access 2010 application but keep getting

Runtime error -2147220973 (80040213) The transport failed to connect to the server

This occurs on the
      .Send
line of code

I use gmail on a private domain.  In Outlook the settings for imap are

Incoming IMAP  imap.gmail.com
Outgoing SMTP   smtp.gmail.com

Server Port

IMAP   993 SSL
SMTP   587 TLS

Thoughts on what is not specified correctly in my code.  Thanks

    Dim cdomsg As Object
    
    Set cdomsg = CreateObject("CDO.message")
    
    With cdomsg.Configuration.Fields
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
        .Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myemail"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
        .Update
    End With
    
    ' build email parts
    With cdomsg
        .To = "recipient@gmail.com"
        .From = "sender@gmail.com"
        .Subject = "Backup Report"
        .TextBody = "the full message body goes here. you may want to create a variable to hold the text"
        .Send
    End With
        Set cdomsg = Nothing

Open in new window

0
Comment
Question by:isurgyn
  • 3
  • 2
5 Comments
 
LVL 10

Accepted Solution

by:
Gozreh earned 500 total points
ID: 39809644
I'm using for the smptserverport 465 and it works great
0
 

Author Comment

by:isurgyn
ID: 39809679
I will admit I hadn't tried port 465 as Outlook was using 587 but am still receiving the same error message even while using port 465.

I am wondering if it could perhaps be Norton antivirus is the problem.  I will plan to try the code from another computer at my office tomorrow unless you have any other thoughts.

Is their potentially a problem with the TLS?  Obviously I know nothing about this type of communication protocol.
0
 

Author Comment

by:isurgyn
ID: 39809688
An additional question is that my email does not have a typical gmail address as we have a private domain although gmail handles all of the email.

As a result this line of code is as follows:

        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myemail@willvision.com"

Perhaps that is an issue here?
0
 
LVL 10

Expert Comment

by:Gozreh
ID: 39810407
I'm also using CDO for my own domain with gmail, and it should work fine.

but you cant use it with TLS, its only giving you the option smtpusessl=True, so if you will use 587 as smptserverport it will not work, only with port 465 it will do the job great.
0
 

Author Comment

by:isurgyn
ID: 39810539
OK I tried the code at the office and it works perfectly.  I think it must be Norton antivirus on my laptop that was the problem.  

Many thanks!
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question