Option Compare Database
Function sndrpt()
Rem <!-- Make sure the Microsoft Object xx.0 Reference Library is enabled & _
(found under Tools>References in the VBA Editor) -->
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim strAttach1 As String
Dim strAttach2 As String
Dim strAttach3 As String
Dim strAttach4 As String
Dim strAttach5 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, "Report1", acFormatRTF, "C:\YourFolder\Report1.rtf", False
DoCmd.OutputTo acOutputReport, "Report2", acFormatRTF, "C:\YourFolder\Report1.rtf", False
DoCmd.OutputTo acOutputReport, "Report3", acFormatRTF, "C:\YourFolder\Report1.rtf", False
DoCmd.OutputTo acOutputReport, "Report4", acFormatRTF, "C:\YourFolder\Report1.rtf", False
DoCmd.OutputTo acOutputReport, "Report5", acFormatRTF, "C:\YourFolder\Report1.rtf", False
'Set Attachments
Rem <!-- make sure to correlate the attachments to each of the reports you wish to send -->
strAttach1 = "C:\YourFolder\Report1.rtf"
strAttach2 = "C:\YourFolder\Report2.rtf"
strAttach3 = "C:\YourFolder\Report3.rtf"
strAttach4 = "C:\YourFolder\Report4.rtf"
strAttach5 = "C:\YourFolder\Report5.rtf"
'Generate email
With objEmail
.To = "
email@removed.com"
.Subject = "Your subject here"
.Body = "Message in body of email here"
.Display
.Attachments.Add strAttach1
.Attachments.Add strAttach2
.Attachments.Add strAttach3
.Attachments.Add strAttach4
.Attachments.Add strAttach5
End With
'Remove attachments from drive
Kill strAttach1
Kill strAttach2
Kill strAttach3
Kill strAttach4
Kill strAttach5
End Function