How to email a pdf document via VBA in access

Posted on 2008-11-19
Last Modified: 2013-11-28
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
Question by:mikkykilo

    Author Comment

    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.

    Accepted Solution

    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 = ""
    '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
    LVL 74

    Expert Comment

    by:Jeffrey Coachman

    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

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now