Results 1 to 7 of 7
  1. #1
    TerraEarth is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2018
    Posts
    86

    Email VBA not working! Run-time error '287'


    Hi,

    I am trying to send emails from access via outlook, which worked completely fine until recently.

    Before I used to be able to write/send automatically generated emails on both my laptop and my work computer.

    Now? On my laptop .send results in the email becoming stuck in the outbox. On my workcomputer, .send does nothing at all. ".Display" works and all the contents of the email are as expected, but .Send does not send the email and close the email window, it leaves the email window up and sends nothing - this is with the On Error GoTo 0 line, without the line error 287 pops up. This error does not pop up on my Laptop but it does pop up on my work computer.

    My program looks like the following:

    Code:
    Option Compare Database
    
    Sub test_email()
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Dim strBody As String
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)
    strBody = "This is a test email. test."
    
    'On Error Resume Next
    With OutMail
        .Display
        .To = "someone@somewhere.com"
        .Subject = "abc 123"
        .Body = strBody
        .Send 'Error 287 on PC, works fine on LAPTOP.
    End With
    'On Error GoTo 0
    
    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub
    Any ideas?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  3. #3
    TerraEarth is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2018
    Posts
    86
    Yes, I always do, whether it is on my laptop or PC.

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I notice that at this point you have 65 views and only one response.
    Could be because there are over 1000 error numbers and just maybe 64 others figured if you can't provide the error message text, they're too lazy to look it up for you.

    Just saying maybe you could help others help you.
    P.S. - call me lazy most times.

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    I've googled using Ms Access error 287 and I find Outlook not open, missing reference to Outlook Object library... I suppose you have looked through the links in Google.

    I would recommend that you use Option Explicit at the top of your modules in addition to
    Option Compare Database

  6. #6
    TerraEarth is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Mar 2018
    Posts
    86
    Quote Originally Posted by Micron View Post
    I notice that at this point you have 65 views and only one response.
    Could be because there are over 1000 error numbers and just maybe 64 others figured if you can't provide the error message text, they're too lazy to look it up for you.

    Just saying maybe you could help others help you.
    P.S. - call me lazy most times.
    Oops.
    Run-time error '287': Application-defined or object-defined error


  7. #7
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Assuming there is no problem with references or variables I would advise you step through the code and see if it works. If it does then the issue is likely that code is running too fast, although given what I see in the code that would not be my first guess. If it turns out to be the case, one method is to introduce a short pause. One thing you are missing is Option Explicit, which should be at the top of every module along with Option Compare. Look under Tools?>Options in vb editor "Require Variable Declaration". Enabling this will not add it to existing modules - you would have to add it manually. Don't be surprised if you compile code and raise errors as a result. No developer worth their salt would not have this turned on.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 04-03-2019, 03:21 PM
  2. Replies: 3
    Last Post: 05-10-2018, 07:48 AM
  3. Replies: 4
    Last Post: 07-23-2015, 09:08 AM
  4. Replies: 4
    Last Post: 06-26-2015, 10:31 AM
  5. Email automation run-time error 2147467259
    By goestejs in forum Access
    Replies: 6
    Last Post: 06-19-2014, 02:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums