Hello All,
I'm working in a code to send some reports through email by clicking a single button, right now I have successfully send a single file without any issue and now I'm attempting to send two files, if you see the code, it first exports the report to PDF and then attaches it to the email.
So far I have duplicated the exporting part so that two different documents are exported and it works fine, the thing is that I don't know how to attach both files in the outlook section, you can see my unsuccessful attempt below, any suggestions?
Code:Private Sub btn_Send_Click() Dim oApp As Object Dim oEmail As Object Dim fileName1 As String, todayDate As String, fileName2 As String todayDate = Format(Date, "MMDDYYYY") fileName1 = "\\mxchi-fs02\danmexshr\BD\Certificaciones\Reports" & "\Report-ExpiringTop_" & todayDate & ".pdf" DoCmd.OutputTo acReport, "Report-ExpiringTop", acFormatPDF, fileName1, False fileName2 = "\\mxchi-fs02\danmexshr\BD\Certificaciones\Reports" & "\Report-ScheduledTop_" & todayDate & ".pdf" DoCmd.OutputTo acReport, "Report-ScheduledTop", acFormatPDF, fileName2, False Set oApp = CreateObject("Outlook.Application") Set oEmail = oApp.CreateItem(0) oEmail.To = DLookup(" [Lista]", "[tbl-sendlist]", "[ID]= 1") oEmail.Subject = "Test" oEmail.Body = "Testing" oEmail.Attachments.Add fileName1 & fileName2 oEmail.Send MsgBox "Email Sent" End Sub


Sending two reports in an email through VBA
Reply With Quote


