INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How can I attach both an Access report and an external PDF to the same email generated within Access

How can I attach both an Access report and an external PDF to the same email generated within Access

How can I attach both an Access report and an external PDF to the same email generated within Access

(OP)


I am trying to attach an internal Access report and an external .pdf file to an email generated within Access. I've read up on the limitations of the SendObject command and it apparently only allows one attachment.

The flip side is to send as an Outlook application, and while it allows multiple attachments they seem to be only external documents located somewhere on one of the drives.

Is it possible to do both? I'm using Access 2007 with SQL Server 2012.

All assistance will be appreciated.

RE: How can I attach both an Access report and an external PDF to the same email generated within Access

I have code that will save the access report as a pdf and then attach it to an email. Since it uses automation of outlook you should be able to code it to then attach the second pdf as well. Would that suffice?

RE: How can I attach both an Access report and an external PDF to the same email generated within Access

(OP)
That would be quite helpful, and I'd appreciate it if you'd send it.

I'm a bit confused because I did get this working myself, and I posted a response here telling others that I had done so, but for some reason the response didn't show up. It's my fault that I really didn't bother to check to confirm.

The method I chose was to use Outlook's multiple attachment features. I used the OutputTo action within Access to output the report as a .pdf file to my C:\ Drive and then I was able to attach the report and the external document to the email together.

I feel really badly that my response didn't show up in the forum. I really appreciate all the selfless work and effort that posters put in here, and I had hoped to let people know that I had it under control. With that said, I'm always looking for alternate ways of doing things and I'd be very interested in whatever information you can send.

RE: How can I attach both an Access report and an external PDF to the same email generated within Access

Did you get the info? If not, the following code assumes that you have at lease access 2007 or later.

CODE -->

 

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.

http://www.thelegacyreturns.com/

RE: How can I attach both an Access report and an external PDF to the same email generated within Access

The code didn't post, so here it is

Function SendMyPDFs()
Dim objOutlook As Object 'Outlook.Application
Dim ItmNewEmail As Object 'Outlook.MailItem
Dim OutputFileName As String
Dim RptName As String
Dim FN As String

RptName = "MyReport" ' The report you want to make into a PDF
FN = "C:\MyReports\MyReport.PDF" ' Where to export your report

Set objOutlook = CreateObject("Outlook.Application")
Set ItmNewEmail = objOutlook.CreateItem(olMailItem)

DoCmd.OutputTo acOutputReport, RptName, acFormatPDF, OutputPDFname, False

With ItmNewEmail
.To = ""
.CC = ""
.Subject = sArgs
.Body = "My Report"
.Attachments.Add FN ' The repoort you just exported
.Attachments.Add "C:\MyReports\My other PDF.PDF" ' The other PDF you want to attach
.Display
End With
End Function

There Are 10 Types Of People In The world:
Those That Understand BINARY And Those That Don’t.

http://www.thelegacyreturns.com/

RE: How can I attach both an Access report and an external PDF to the same email generated within Access

(OP)
Thank you very much. It is quite similar to the code I wound up using.

As this code does, I wound up using the OutputTo command to turn the report into a .pdf at a known location on the hard drive, and then I attached the report and the other document that I was trying to add using Outlook rather than SendObject commands, as you have done here.

I actually think your code is a bit cleaner than mine, but at this point it's working well and I probably won't revisit it just to make it prettier.

I honestly appreciate all of the efforts that everyone here puts forth to help others. It takes a special kind of person do do this at the going pay rate!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close