[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

How to email a pdf document via VBA in access

I have my report in access which i want to be sent as a pdf, am using cute pdf writer to convert it to a PDF now i need a function which will attatch the pdf into an email so the user clicks the button to email then it user cute pdf writer to convert then attatches the created pdf to an email, any assistance would be great. Thanks
  • 2
1 Solution
mikkykiloAuthor Commented:
Hey found soloution on my own so do not need help with this qestion any more, thnks anyway, not sure how to remove question though.
mikkykiloAuthor Commented:
And for those who are curious, this is the code i used.
This created the pdf using cute pdf ceator, and waits for ok then emails report.
   stDocName = "rptInvoice"
   Set Application.Printer = Application.Printers("CutePDF Writer")
   DoCmd.OpenReport stDocName, acViewNormal
   Application.Printer = Nothing
   MsgBox ("Press ok once pdf is created")
Dim objOutl
Set objOutl = CreateObject("Outlook.Application")
Set objMailItem = objOutl.CreateItem(olMailItem)
'comment the next line if you do not want to see the outlook window
'strEmailAddr = "me.me@you.com"
'objMailItem.Recipients.Add strEmailAddr
objMailItem.Body = "Please see attatched invoice."
objMailItem.Attachments.Add "i:\DNR_Database\invoicetemp\invoice.pdf"
Set objMailItem = Nothing
Set objOutl = Nothing
Jeffrey CoachmanCommented:

I used to use Cute PDF as well.

And perhaps this functionality could have been easilly achieved.

I now use this instead:

This problem with your request is that:
1. After your code is run it will have created a PDF from the report, even it the PDF file existed already.
It will also create a new PDF for the same Report over and over again, for the same report, each time you click the button.

Here is a sample anyway, to get you started.

You will have to get a program to bypass the Outlook security pop-up.
Outlook Redemption:

You will also need to load the Outlook library in VBA.


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now