hi
im trying to create a sub to be able to email multiple attachments in the same email, i cant use send object as it will only allow one attachment, i want to be able to send a report and a query as an excel format, how can i do this without having to save it on the computer first?
the code below wants to save it to the desktop first
im trying to create a sub to be able to email multiple attachments in the same email, i cant use send object as it will only allow one attachment, i want to be able to send a report and a query as an excel format, how can i do this without having to save it on the computer first?
the code below wants to save it to the desktop first
Code:
Private Sub EmailReport_Click()
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")
fileName1 = Application.CurrentProject.Path & "\ReportName_" & todayDate & ".pdf"
DoCmd.OutputTo acReport, "Report_ENG_MCU_InServiceIssues", acFormatPDF, fileName, False
fileName2 = Application.CurrentProject.Path & "\QueryName_" & todayDate & ".pdf"
DoCmd.OutputTo acQuery, "Query_ENG_MCU_ForRS", acFormatPDF, fileName, False
'Email the results of the report generated
Set oEmail = oApp.CreateItem(olMailItem)
With oEmail
.Display
.Recipients.Add ""
.Subject = "In Service Issues"
.Body = "Hi All" & CHR$(13) & CHR&(13) & "Here is the in service issues for today"
.Attachments.Add fileName1
.Attachments.Add fileName2
'.Send
End With
MsgBox "Email successfully sent!", vbInformation, "EMAIL STATUS"