Runtime error 287. Sending Emails through Outlook using VBA in Access

Well this is something I have never come across before, however, I have found a solution.

The error message itself got me wondering why the send command wasn’t recognising the defined application. I questioned whether the code was running too fast. (I don’t know where this light bulb moment came from but it has fixed the issue).

I have simply inserted a loop to force a delay before the send operation. I did this because Access doesn’t recognise application.wait.

Testing so far seems successful!

Dim T1 As Variant
Dim T2 As Variant

T1 = Now()
T2 = DateAdd("s", 1, T1)

Do Until T2 <= T1
    T1 = Now()
Loop
oMail.Send

This procedure will not be run very often, maybe 5 times in a day max. So I am not worried about the one second delay causing any real-time issues.

Leave a Comment