Send Email With Attachment (report) Via Outlook Using Vba
Thank you for taking the time to report an issue.
What's wrong... Please write below.
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 (in the above code).
Worst comes to worst, I'll try to figure out a way to save the report as a PDF (to the local filesystem) and then attach that as one of the attachments.
I need to create a form that opens which automatically runs a report and sends an email without a user. Meaning that some how I need to bypass the Outlook security message. This is the code I am currently using to send the email out
I'm looking to accomplish this through VBA and I have tried everything that I can think of and still am unable to get it to work.
When a user sends an email from Access through Outlook I would like to attach this file (if there is one stored in that record).
Sending and everything works fine, but how do I select the attachment to get it into the email?
This is the attachment part in my email code:
If Not IsMissing(xxxx) Then
Set objOutlookAttach = .Attachments.Add(xxxx
Dim objOutlook As Outlook.Application Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application") Set objEmail = objOutlook.CreateItem(olMailItem) Set thereport = CurrentDb.OpenRecordset("Harmonogram")
Email = Me.Email
With objEmail .To = Email .Subject = Harmonogram .Body = text .Attachments.Add thereport, olByReference, 1, "Harmonogram" .Display End With
Set objEmail = Nothing
I have found this code on Internet but there is a problem in line: .Attachments.Add thereport, olByReference, 1, "Harmonogram". It shows me an error message: Data type conversion error. - 3421.
I've written the script to generate the email, attach the report (actually in the body of theemail) and send it to the correct people.
My issue is that I want to send only the relevant records from the report to each person. I've put the relevant person's email into the report (of a query) to make it easier. I want to email all the records with one email address to that email address and so on.
This would mean, for example, there are 6 records with [@email] in the email field of the report and 3 records with [@email]. I want the 6 records with [@email] to be emailed to [@email]and the 3 records with [@email] to be emailed to [@email].
Since, the report I'm trying to send is an access object it is not stored at a particular path on the PC/network.
Can anyone tell me how I can detect whether the "Send" button on the email message was clicked on from within Access VBA?
Is there any way to design a Macro that will let you do this