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
.Body = "The Database Employee Contact has been updated"
.Subject = "New Entry Employee Contact"
.To = "email address"
If AutoSend Then
Set oMail = Nothing