?
Solved

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

Posted on 2014-01-25
5
Medium Priority
?
6,772 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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