Results 1 to 8 of 8
  1. #1
    pdevito3 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2013
    Posts
    35

    Emails and 287 error

    I am writing a batch email procedure (note this is multiple emails to individuals done through a loop, not 1 email to a lot of people) and I keep getting a 287 error when I use ".Send" but ".Display" is working just fine. I've provided two bare bone code examples for simplicity sake below; both throw a 287 error.



    I've also tried the "DoCmd.SendObject" function shown below, but get outlook security prompts (which are docmd.setwarning proof as far as I can tell) for each and every email. To add, they are not even the "time allowance" prompt that allow access for "x" minutes.

    Does anyone know what's going on below and/or had any luck with batch emails like this in the past?

    Thanks

    Code:
    Sub mailTest()
    Dim oApp As outlook.Application
    Set oApp = New outlook.Application
    Dim oMI As outlook.MailItem
    Dim x As Integer
    For x = 1 To 2
        Set oMI = oApp.CreateItem(olMailItem)
        oMI.Body = "test message"
        oMI.Subject = "message from access"
        oMI.To = "email" & x & "@test.com"
        oMI.Send '.Display works fine
    Next x
    Set oMI = Nothing
    Set oApp = Nothing
    End Sub
    Code:
    Sub mailTestTwo()
    Dim OutApp              As Object
    Dim OutMail             As Object
    Dim x As Integer
    Set OutApp = CreateObject("Outlook.Application") 
        
    For x = 1 To 2
        Set OutMail = OutApp.CreateItem(0)
        With OutMail
            .To = "email" & x & "@test.com"
            .CC = ""
            .BCC = ""
            .Subject = "Test"
            .Body = "Test Bod"
            .Send 'Display works
        End With
    Next x
    Set OutApp = Nothing
    Set OutMail = Nothing
    End Sub
    This throws the outlook prompt every time to allow sending
    Code:
    DoCmd.SendObject acSendNoObject, , , test@test.com, , , "Test - " & Date, bodyStr, False 'False to send, True to display

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    What is the exact message of the 287 error?

    Try sending to a real email address, like to yourself.

    Your Set oApp statement may not be correct. I use CreateObject. And maybe clear the oMI variable within the loop. Although examples I've seen don't even clear the Outlook objects at all.

    Code:
    Sub mailTest()
    Dim oApp As outlook.Application
    Dim oMI As outlook.MailItem
    Dim x As Integer
    Set oApp = CreateObject("Outlook.Application")
    For x = 1 To 2
        Set oMI = oApp.CreateItem(olMailItem)
        oMI.Body = "test message"
        oMI.Subject = "message from access"
        oMI.To = "email" & x & "@test.com"
        oMI.Send '.Display works fine
        Set oMI = Nothing
    Next x
    Set oApp = Nothing
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    pdevito3 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2013
    Posts
    35
    Using CreateObject didn't seem to do the trick either. I tried with my personal email address and it didn't seem to make a difference.

    This all just seems especially weird that it makes the object just fine and performs the display action correctly, even sending it from the display correctly, but doesn't execute the send action correctly.

    The error description is "application defined error or object defined error"

    Have you done bulk email like this before? If so, using what method?

    Thanks, June7

  4. #4
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    I am not sure if this is your problem.

    I have tested your original code. It gives me "Undeliverable: Test" mail twice. That is because the email have "1" and "2" as part of the name.

    Once I change the correct email address. It deliver fine without any issue.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I haven't used bulk except to help other posters with code. So I just tested your code with my email and it works perfectly.

    Seems that error usually means the correct VBA library is not referenced. But I presume you have Outlook library selected in References, otherwise would error earlier in the code.

    Possibly something about your network permissions.

    Or maybe set Outlook options: File > Options > Trust Center > Trust Settings > Programmatic Access > my choice is "Warn me about suspicious activity when my antivirus software is inactive or out-of-date (recommended)."

    Another option is to use CDO for email. But your network might be even more restrictive on this.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    pdevito3 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2013
    Posts
    35
    Gotcha. Yes I have the outlook library referenced. I think it's probably a network permissions issue. Familiar with the programmatic access option, but that won't be possible in scenario. Looking into CDO as well, but not expected that to be viable in this option either.

    Appreciate the input and time!

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I also have this line before .Send

    .DeleteAfterSubmit = True

    Maybe that will help you.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    pdevito3 is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Aug 2013
    Posts
    35
    No dice. Thanks though!

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

Similar Threads

  1. Sorting Emails
    By WhiskyLima in forum Access
    Replies: 13
    Last Post: 10-23-2013, 04:12 AM
  2. Pricing Emails
    By Nibbles in forum Access
    Replies: 0
    Last Post: 08-20-2013, 12:54 AM
  3. Attachments to Emails
    By MrChips in forum Access
    Replies: 8
    Last Post: 09-01-2012, 11:17 AM
  4. Emails with a Macro
    By srcacuser in forum Access
    Replies: 5
    Last Post: 05-02-2012, 11:49 AM
  5. Automatic Emails
    By smit2215 in forum Queries
    Replies: 1
    Last Post: 03-10-2011, 01:23 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