Here's my code, to 'auto-generate' an e-mail, at the triggering of an event ....
I get the following error message - " Error occurred at EMail_Via_Outlook: 287; Application defined or object defined error ( see MsgBox code )
Code:
Public Function Email_Via_Outlook(varAddress, varSubject, varBody)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
On Error GoTo errorHandler
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add(varAddress)
objOutlookRecip.Type = olTo
.Subject = varSubject
.Body = varBody
.Send
End With
errorHandler:
errNameFrom = "Email_Via_Outlook"
MsgBox "Error occured at " & errNameFrom & ": " & Err.Number & "; " & Err.Description
End Function
I get the following error message - " Error occurred at EMail_Via_Outlook: 287; Application defined or object defined error ( see MsgBox code )