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

Access 2007 use VBA to Send Report as a PDF attachment to Outlook without Security Msgs


I need to email out a bunch of statements to different recipients
I started using    DoCmd.SendObject acSendReport, rptName, acFormatPDF, Recipient etc
But I get the security messages from Outlook that I don't want the user to see.

So I am now trying a different approach
I am OK using VBA code to send an email with an attachment using something like
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
     With MailOutLook
        .To = Recipient
        .subject = subject
        .Body = message
        .Attachments.Add (attach_file)
     End With

But I can't quite work out how to get the report as a PDF to attach to the email
This may be the simple  part but just can't see it

A bit of code would be lovely!

Many thanks

  • 2
  • 2
1 Solution
Kelvin SparksCommented:
You first need to create the pdf.

DoCmd.OutputTo acOutputReport,rptname,acFormatPDF,outputfile,False

Where you create the pdf file - outfile would be the full file path.

Then use .Attachments to attach that file (delete it after if you need).

You will find, however, that the Outlook security message will still get in the way, and I'd be keen to see if anyone else has a simple answer to that. Are you using a local Outlook, or part of an Exchange mmailserver type of setup?

stillers1994Author Commented:
Hello Kelvin
Thankyou for your quick reply
I believe they will be using a local Outlook.
I just want to get rid of those security messages
If this method doesn't do that then I suppose you have saved me the trouble of continuing down that route (and answered my question)
Does anyone have the solution of avoiding the security messages?
Or do I have to open a new question?
Kelvin SparksCommented:
Had a quick look on EE

There are a number of questions relating to that with various solutions.

Local Outlook is possibly easier to manage.

stillers1994Author Commented:
I guess your answer is as per my question.
I had a good look on EE before but couldn't quite find the answers. I will look again and mayb re-phrase my question
Many thanks
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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