Hello,
While searching this forum, I found some code that would work for emailing reports (thank you, June7!). When I click the button, my process is working fine, but I would like this process to select one email address from the recordset, with its' corresponding detail, and allow me to send only that detail to the email address selected. After that email is sent, this should select the next email address, and detail corresponding to that email address and so on, until the process has gone through the entire recordset.
My test data includes three email addresses, and several transactions for each. The report has a break to keep each email/dataset to it's own page, but when the process runs, the report gives me all three pages, which will then get sent to each email address. I don't mind having to click "Send" for each email, I just don't want each person to get someone else's data.
Here is the code I am using:
Private Sub cmdEmailToRequestors_Click()
Dim rs As DAO.Recordset
stCaption = "EFT Payments sent" & Format(Now(), " mm-dd-yyyy")
myPath = "\\DFS01\SHARED\CFA\VOL5\TREASURE\CASH_MGR\1- Treasury Operations\4- Database\Wire Tracking\"
stEmailMessage = "Please see the attached report for EFT Payments processed today."
stSubject = "EFT Payments"
stReport = "rptEmailToRequestors"
Set rs = CurrentDb.OpenRecordset("SELECT RequestorEmail FROM tblRequestors;")
DoCmd.OpenReport "rptEmailToRequestors", acViewPreview
While Not rs.EOF
DoCmd.SendObject acSendReport, , acFormatPDF, rs!RequestorEmail, , , stSubject, stEmailMessage, True, ""
DoCmd.OutputTo acOutputReport, , acFormatPDF, myPath & stCaption & ".pdf", False, , acExportQualityPrint
rs.MoveNext
Wend
DoCmd.Close acReport, stReport, acSaveNo
rs.Close
End Sub
Thank you, in advance!!
VCoutu