Solved

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

Posted on 2014-01-25
5
6,020 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now