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

旧街凉风 提交于 2019-11-28 01:24:57

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!