Results 1 to 5 of 5
  1. #1
    VWSpeedyB is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Location
    Work in Center Valley, PA, live near Philadelphia, PA
    Posts
    25

    VBA code to use Office 365 from Access 2010 - Run-time error

    Good morning Access Guru's -

    It's been a very long time since I've posted, because all of your previous assistance has worked out so well. I've been able to tweak what you shared to grow my DB. However, I now find myself in quite the conundrum....my company as switched from previous Gmail platform to Office 365.

    I googled and found VBA code to convert modules to send e-mail from Access 2010 using O365. However, I am constantly receiving the following Run-time Error:

    "Run-time error '-2147220973 (80040213'):

    The transport failed to connect to the server."

    Attached is the code I'm attempting to use.

    [Public Sub BDP_Import_SKU_List_Full_Upld2()

    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/smtpauthentication") = 1
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com"
    '.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 180
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "My-email"


    .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "My-Password"
    .Update
    End With


    With cdoMsg
    DoCmd.Close acReport, "close active report"
    DoCmd.OpenQuery "update date query", acVierNormal 'track date of last action
    DoCmd.OpenReport "re-open active report" 'after date refresh
    DoCmd.Maximize


    End With


    With cdoMsg
    .To = "email recipients"
    .CC = "copy recipients"
    .From = "my-email"
    .Subject = "DBP - " & _
    "" & _
    "" & _
    "Thank you," & _
    "" & _
    "" & _
    "Salutation"
    .AddAttachment ("Z:File Path\filemname.xlsx")
    .Send


    End With








    End Sub


    Public Static Function public_Function_name()
    Call public_sub_name
    End Function]


    Please review and advise what/how I can make this work. Please note, I'm still extremely green when it comes to writing code. Everything here I have garnered from your previous inputs, and web-searches.

    As always, thank you very much for your time. I truly appreciate all of the help you have provided in the past.


    Bryon

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    I notice the below line is commented out in your code. I think you need it. I do with my CDO code using gmail server. Also you could try port 25.
    Code:
    '.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587

  3. #3
    VWSpeedyB is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Location
    Work in Center Valley, PA, live near Philadelphia, PA
    Posts
    25
    Davegri -

    Thank you for the suggestion. Unfortunately, I have received the same error adding the code line; and using both ports. I will have to follow up with my IT team, as the process may be failing at the server side; and not with the function itself.

  4. #4
    VWSpeedyB is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Location
    Work in Center Valley, PA, live near Philadelphia, PA
    Posts
    25
    Ok....finally got this working.

    Added the line of code, but had to key a new module from scratch; with no copy/paste. Once that was done, it worked fine.

    Thanks again Davegri!

  5. #5
    kkcat is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2019
    Posts
    1
    VWSpeedyB - I have got the same situation with you, could you pls tell me how did you solve it. Many thx

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 02-01-2016, 08:27 AM
  2. Replies: 4
    Last Post: 08-19-2014, 12:20 PM
  3. Run Time Error '91' Problem - Access 2010 VBA
    By mick5003 in forum Programming
    Replies: 3
    Last Post: 03-21-2013, 08:06 AM
  4. Replies: 9
    Last Post: 06-08-2012, 07:52 AM
  5. DateAdd error in MS Office 2010
    By Noah4x4 in forum Access
    Replies: 7
    Last Post: 03-15-2011, 05:08 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums