Solved

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

Posted on 2014-01-25
5
6,313 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

726 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