Good morning,
I currently have an email process, with an attached report, that when the button is clicked, the email comes from that person who clicked the button. I would like to use the SentOnBehalfOfName to send the email from a specific mailbox, but I am getting an error message: Run-time error '91': Object variable or With block variable not set.
I am not sure what this error message is telling me, any help is appreciated!
Here is my code:
Private Sub cmdEmailToRequestors_Click()
Dim rs As DAO.Recordset
Dim myItem As Object
myPath = "\\DFS01\SHARED\CFA\VOL5\TREASURE\CASH_MGR\1- Treasury Operations\4- Database\Wire Tracking\"
stEmailMessage = "Attached is a report for disbursements released today per your request. If you would no longer like to receive this notification, please inform us and we will remove you from the distribution list accordingly. Best regards, Treasury Operations"
stSubject = "EFT Payments sent" & Format(Now(), " mm-dd-yyyy")
stReport = "rptEmailToRequestors"
Set rs = CurrentDb.OpenRecordset("SELECT DISTINCT RequestorID, RequestorEmail FROM qryEmailToRequestors WHERE [DateDue]=Date();")
While Not rs.EOF
myItem.SentOnBehalfOfName = "Wireroom@hanover.com"
DoCmd.OpenReport "rptEmailToRequestors", acViewPreview, , "RequestorID=" & rs!RequestorID & " AND [DateDue]=Date()"
DoCmd.SendObject acSendReport, , acFormatPDF, rs!RequestorEmail, , , stSubject, stEmailMessage, True, ""
DoCmd.OutputTo acOutputReport, , acFormatPDF, myPath & stSubject & ".doc", False, , acExportQualityPrint
DoCmd.Close acReport, stReport, acSaveNo
rs.MoveNext
Wend
MsgBox "All emails have been sent."
rs.Close
End Sub
Thanks,
Vickster3659