I have a code for email the whole report to the one recipient. How to print the report separately by customer id with pdf format and email them to related customer?
Code:
Private Sub Command0_Click()
On Error GoTo Err_Handler
Dim oApp As New Outlook.Application
Dim oEmail As Outlook.MailItem
Dim fileName As String, todayDate As String
'Export report in same folder as db with date stamp
todayDate = Format(Date, "MMDDYYYY")
fileName = Application.CurrentProject.Path & "\Goodies_" & todayDate & ".pdf"
DoCmd.OutputTo acReport, "MYreport", acFormatPDF, fileName, False
'Email the results of the report generated
Set oEmail = oApp.CreateItem(olMailItem)
With oEmail
.Recipients.Add "myemail@gmail.com"
.Subject = "Free Gift"
.Body = "With Compliment"
.Attachments.Add fileName
.Send
End With
MsgBox "Email successfully sent!", vbInformation, "EMAIL STATUS"
End Sub