kevinh2320
Board Regular
- Joined
- May 13, 2016
- Messages
- 61
I'm trying to email three reports in the MS Access database as PDF attachments in one email. The report names are highlight in red below. I found this code and modified it to use for this situation but, I'm getting a "compile error - user-defined type not defined" error right on the first line "Dim objOutlook As Outlook.Application". I'm new to VBA and don't know how to fix this. Thanks for any help.
Private Sub email_cirr_lss_rpts_Click()
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim strAttach1 As String
Dim strAttach2 As String
Dim strAttach3 As String
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'Output Reports
Rem <!-- change "Reportx" to match the report names you wish to export. & _
IMPORTANT: Make sure the location you select to save your reports to exists, Access will & _
not create the folders for you. -->
DoCmd.OutputTo acOutputReport, "r_cirr_lss_call_Log_detail", acFormatPDF, "F:\CIRR_LSS Call Log\Reports", False
DoCmd.OutputTo acOutputReport, "r_cirr_lss_call_Log_summary", acFormatPDF, "F:\CIRR_LSS Call Log\Reports", False
DoCmd.OutputTo acOutputReport, "r_cirr_lss_call_Log_individual", acFormatPDF, "F:\CIRR_LSS Call Log\Reports", False
'Set Attachments
Rem <!-- make sure to correlate the attachments to each of the reports you wish to send -->
strAttach1 = "F:\CIRR_LSS Call Log\Reports\r_cirr_lss_call_Log_detail"
strAttach2 = "F:\CIRR_LSS Call Log\Reports\r_cirr_lss_call_Log_covid19_requests"
strAttach3 = "F:\CIRR_LSS Call Log\Reports\r_cirr_lss_call_Log_covid19_approved"
'Generate email
With objEmail
.To = "test@test.com;test2@test.com"
.Subject = "CIRR LSS Call Log Report"
.Body = "CIRR LSS Call Log Report"
.Display
.Attachments.Add strAttach1
.Attachments.Add strAttach2
.Attachments.Add strAttach3
End With
End Sub
Private Sub email_cirr_lss_rpts_Click()
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim strAttach1 As String
Dim strAttach2 As String
Dim strAttach3 As String
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'Output Reports
Rem <!-- change "Reportx" to match the report names you wish to export. & _
IMPORTANT: Make sure the location you select to save your reports to exists, Access will & _
not create the folders for you. -->
DoCmd.OutputTo acOutputReport, "r_cirr_lss_call_Log_detail", acFormatPDF, "F:\CIRR_LSS Call Log\Reports", False
DoCmd.OutputTo acOutputReport, "r_cirr_lss_call_Log_summary", acFormatPDF, "F:\CIRR_LSS Call Log\Reports", False
DoCmd.OutputTo acOutputReport, "r_cirr_lss_call_Log_individual", acFormatPDF, "F:\CIRR_LSS Call Log\Reports", False
'Set Attachments
Rem <!-- make sure to correlate the attachments to each of the reports you wish to send -->
strAttach1 = "F:\CIRR_LSS Call Log\Reports\r_cirr_lss_call_Log_detail"
strAttach2 = "F:\CIRR_LSS Call Log\Reports\r_cirr_lss_call_Log_covid19_requests"
strAttach3 = "F:\CIRR_LSS Call Log\Reports\r_cirr_lss_call_Log_covid19_approved"
'Generate email
With objEmail
.To = "test@test.com;test2@test.com"
.Subject = "CIRR LSS Call Log Report"
.Body = "CIRR LSS Call Log Report"
.Display
.Attachments.Add strAttach1
.Attachments.Add strAttach2
.Attachments.Add strAttach3
End With
End Sub