Solved

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Preface There are many applications where some computing systems need have their system clocks running synchronized within a small margin and eventually need to be in sync with the global time. There are different solutions for this, i.e. the W3…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

758 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

21 Experts available now in Live!

Get 1:1 Help Now