• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • 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 CoachmanMIS LiasonCommented:

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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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