Why does SMTP email method produce 0x800ccc0b Error

125 Views Asked by At

Using Microsoft Access (VBA) I have the following Email function using reference to the "Microsoft CDO for Windows 2000 Library".

Public Sub SendEmail()

    Dim Mail As CDO.Message
    Set Mail = New CDO.Message

    With Mail.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") = 587
        .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/smtpauthenticate") = 1
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "####"
        .Update
    End With
    
    With Mail
        .To = "[email protected]"
        .From = "[email protected]"
        .subject = "Test Email"
        .TextBody = "Testing, please do not reply!"
        .Send
    End With
    
End Sub

Whilst on most occasions this will work as expected, I have encountered the below message which I believe is when emails are sent in quick succession.

enter image description here

This will then freeze up the application preventing other emails from being sent etc until the application is closed completely. What would be best practice to catch when this error occurs to close the object and prevent sending (returning a false boolean value?) allowing the user to reattempt sending the message?

0

There are 0 best solutions below