I am building a database that will send emails to users and their managers. I need to have code built in that will log information if Outlook receives an error while trying to send. I am in between beginner and intermediate skill levels with Access and VBA, so I'm not entirely sure where to begin. I've included my function below and would like to place this bit of code with the "On Error GoTo 0" line.
Code:
Public Function SendSDEmail(eSubject As String, eBody As String, eBody2 As String, eTo As String, eCC As String, eBCC As String, sig As String) As Boolean 'function to be used when sending emails out
Dim OutApp As Object, OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = eTo
.CC = eCC
.BCC = eBCC
.SentOnBehalfOfName = ""
.Subject = eSubject
.Display
.HTMLBody = eBody & eBody2 & sig
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Function