CDO Email Error Handeling (1 Viewer)

fenhow

Registered User.
Local time
Today, 03:40
Joined
Jul 21, 2004
Messages
599
Hi, I have the following code to email some reports out of my access DB. This runs automatic with a task scheduler and works perfect except when my internet connection is down (happens quite often), the problem is when there is not internet and the CDO cannot complete it hangs my program and the task scheduler will not close the process.

Is there a way to add some error handling to this code so if after a certain amount of time or if there is no connection it kills and ends the code?

Many thanks.
Fen

Public Function send_email_reports()

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."
.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") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = ""
.Update
End With
' build email parts
With cdomsg
.To = "@gmail.com"
.From = ""
.Subject = " Daily Reports Attached " & Date & "-" & Time
.TextBody = "Daily DriveNow Reports. *** This is an automatically generated email, please do not reply. . ***"""

.AddAttachment ("")

.Send
End With
Set cdomsg = Nothing
End Function
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 11:40
Joined
Jul 9, 2003
Messages
16,287
You might be able to modify the error checking in this sample I wrote. The sample allows you to send Gmail from MS Access (or any VBA application I reckon)

Gmail From MS Access
 

Users who are viewing this thread

Top Bottom