none
Send email via Microsoft Access using SMTP code through Office 365 email RRS feed

  • Question

  • Here is the test code with the Office 365 email settings.  I am receiving the error: The transport failed to connect to the server.

    Please review the settings and the code below and advise.   Thankyou

        Dim iMsg As Object

        Dim iConf As Object
        Dim strbody As String
        Dim Flds As Variant
        Set iMsg = CreateObject("CDO.Message")
        Set iConf = CreateObject("CDO.Configuration")
            iConf.Load -1
            Set Flds = iConf.Fields
            With Flds
                .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "safechoice-com.mail.protection.outlook.com" 
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
                .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Tim@SafeChoice.com"
                .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mypassword
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
                .Item("http://schemas.microsoft.com/cdo/configuration/sendtls") = True
                .Update
            End With
        strbody = "Testing"
        With iMsg
            Set .Configuration = iConf
            .To = "TimothyABrannon@verizon.net"
            .CC = ""
            .BCC = ""
            .From = "Tim@SafeChoice.com"
            .Subject = "Important message"
            .TextBody = strbody
            .Send
        End With

        Set iMsg = Nothing
        Set iConf = Nothing
        Set Flds = Nothing
    '***************************


    Tuesday, March 24, 2020 5:47 PM

All replies

  • Hi,

    Thanks for visiting our forum, here we mainly focus on general issues about Outlook desktop client but your question is more related to Outlook for developers. So I'll move your thread to the dedicated forum for Outlook for developers.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thanks for your understanding and hope your question will be resolved soon.

    Regards,

    Aidan Wang


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Wednesday, March 25, 2020 2:48 AM
  • SMTP server is smtp.office365.com, you connection must use TLS on port 587.

    Try to create a test POP3/SMTP account in Outlook to test the connection and its parameters. You might want to specify a dummy POP3 server to avoid downloading messages from your Exchange mailbox.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!


    Wednesday, March 25, 2020 3:01 AM

  • Oskar Shon, Office System MVP - www.VBATools.pl
    if Helpful; Answer when a problem solved

    Thursday, April 2, 2020 11:55 AM