Troubleshooting NonOutlook Email Code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ricardo de Mila
    New Member
    • Jan 2011
    • 41

    Troubleshooting NonOutlook Email Code

    (Split from: How to make Access to send an e-mail without using outlook. )

    Hi Seth...
    It has been a long time since you have answered my question. I've starting my studies using the outlook as a way to transmit my e-mails from Access and just now I tryed to use Gmail as the server.
    But after copying the code of the link you have suggested into my code, I got the following error:

    Fail in the conection of the transport with the server.
    CDO.Message 1

    Could you please help me to understand what is wrong?
    My code is written below:

    Code:
    Private Sub Comando3_Click()
    On Error GoTo Err_Comando3_Click
    
    Set cdomsg = CreateObject("CDO.message")
        With cdomsg.Configuration.Fields
             .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'NTLM method
             .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
             .Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 465
             .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") = 60
             .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mygmail@gmail.com"
             .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
             .Update
        End With
    
       ' build email parts
       With cdomsg
            .To = "somebody@somedomain.com"
             .From = "mygmail@gmail.com"
             .Subject = "Test"
             .TextBody = "Teste."
             .Send
        End With
    
        Set cdomsg = Nothing
        
    Exit_Comando3_Click:
        Exit Sub
        
    Err_Comando3_Click:
        Call ErrMsg("Private Sub Comando3_Click()")
        Resume Exit_Comando3_Click
        
    End Sub
    I got the error in the .send procedure.
    Could you please help me?
    Best regards
    Last edited by zmbd; Sep 25 '16, 05:26 AM. Reason: [z{please use the [CODE/] formatting tool when posting VBA/SQL-scripts}]
  • Seth Schrock
    Recognized Expert Specialist
    • Dec 2010
    • 2965

    #2
    What is the error number?

    Comment

    • Ricardo de Mila
      New Member
      • Jan 2011
      • 41

      #3
      Hi Seth... Thank you for replying.
      The error I got was:
      "It was not possible to send the message to the SMTP server. The transport error code was 0x80040217.The server answer was 'not available'"

      Translated from portuguese.

      Best regards
      Ricardo de Milano

      Comment

      • Seth Schrock
        Recognized Expert Specialist
        • Dec 2010
        • 2965

        #4
        I need the error number as well as the description. You have given me the description, now I just need the number. Is it -2147220973 by any chance? Since it says SMTP error, try port number 587 instead of 465.

        Comment

        • Ricardo de Mila
          New Member
          • Jan 2011
          • 41

          #5
          Hi Seth...
          Thank you for replying.
          Yes the error number -2147720973. But I have also tryed with the port number 587 and the result was the same.
          I've heard that google is accepting just 465 and that's why I have tryed it.
          I also have an information on my screen saying that the source of the error was on CDO.Message.1.

          Thank you for helping.

          Best regards
          Ricardo de Milano

          Comment

          Working...