Results 1 to 3 of 3
  1. #1
    Join Date
    May 2014
    Provided Answers: 2

    Unanswered: Auto sending email when form updated

    I have the following code to send an email when a new record is entered into a table from a form that works great if Outlook is open. If Outllok is not the then the record is properly updated but no email sent error message Run-time error '287': Appication-defined or object-defined error.

    When you click debug .Send is highlighted.

    Any thoughts on how to open Outlook with the code I am using?

    Private Sub Form_AfterUpdate()
    Dim myOb As Object
    Dim AutoSend As Boolean
    Set myOb = CreateObject("Outlook.Application")
    Set oMail = myOb.CreateItem(olMailItem)
    AutoSend = True
    With oMail
        .Body = "The Database Employee Contact has been updated"
        .Subject = "New Entry Employee Contact"
        .To = "email address"
        If AutoSend Then
        End If
    End With
        Set oMail = Nothing
    End Sub

  2. #2
    Join Date
    May 2014
    Provided Answers: 2
    Is there some way to open Outlook?

  3. #3
    Join Date
    Jul 2004
    South Dakota
    Skip Outlook completely. Search for sending email with CDO. Let me know if you still need help. I have some code I can share but it's back at the office.

    Found this from an old pay post of mine... Should get you started.

    Last edited by canupus; 12-13-15 at 23:45. Reason: Added link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts