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

前端 未结 1 1996
臣服心动
臣服心动 2020-12-02 00:51

I have a case where one user would like to receive notifications of when deliveries are added to an Access Database. The simplest method I could think of was to set up an au

相关标签:
1条回答
  • 2020-12-02 01:34

    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.

    0 讨论(0)
提交回复
热议问题