Hey guys
Scenario: User is looking at a job details. Job has pictures and PDF's as external files saved in the filesystem of the computer. User clicks Email Invoice. System attaches report as a PDF and opens Outlook Email message with email address, subject and body filled and the report PDF as an attachment
I can currently send a report as an attachment in an Outlook Email by using the "DoCmd.SendObject acSendReport" code.
That works nicely for me because it attaches the report I specify but has the limitation that I cannot attach any other objects.
I therefore came across the following code which allows me to add multiple attachments to an Outlook email message:
The problem with the above is that I cannot figure out how to attach a report of my choice. I don't know if there is a way to tell access to open a report and attach it as a PDF.
Worst comes to worst, I'll try to figure out a way to save the report as a PDF and then attach that as one of the attachments.
Scenario: User is looking at a job details. Job has pictures and PDF's as external files saved in the filesystem of the computer. User clicks Email Invoice. System attaches report as a PDF and opens Outlook Email message with email address, subject and body filled and the report PDF as an attachment
I can currently send a report as an attachment in an Outlook Email by using the "DoCmd.SendObject acSendReport" code.
That works nicely for me because it attaches the report I specify but has the limitation that I cannot attach any other objects.
I therefore came across the following code which allows me to add multiple attachments to an Outlook email message:
Code:
Sub CreateEmail()
'write the default Outlook contact name list to the active worksheet
Dim OlApp As Object
Dim OlMail As Object
Dim ToRecipient As Variant
Dim CcRecipient As Variant
Set OlApp = CreateObject("Outlook.Application")
Set OlMail = OlApp.createitem(olmailitem)
For Each ToRecipient In Array("User 1", "User 2", "User 3")
OlMail.Recipients.Add ToRecipient
Next ToRecipient
For Each CcRecipient In Array("User 4", "User 5", "User 6")
With OlMail.Recipients.Add(CcRecipient)
.Type = olCC
End With
Next CcRecipient
'fill in Subject field
OlMail.Subject = "Test of Outlook email"
'Add the active workbook as an attachment
OlMail.Attachments.Add "C:\Users\User\Pictures\Unspecified\01.jpg"
OlMail.Attachments.Add "C:\Users\User\Pictures\Unspecified\02.jpg"
'Display the message
OlMail.Display 'change this to OlMail.Send if you just want to send it without previewing it
End Sub
The problem with the above is that I cannot figure out how to attach a report of my choice. I don't know if there is a way to tell access to open a report and attach it as a PDF.
Worst comes to worst, I'll try to figure out a way to save the report as a PDF and then attach that as one of the attachments.