logo
search
VBA & Macro Problems

How to Send an Access Email with Two PDF Attachments via VBA

Partner EditorPartner Editor Sep 28, 2026 869 views

Question details

The user needs to send a single email containing two PDF attachments from Microsoft Access using a command button.

How to Send an Access Email with Two PDF Attachments via VBA
Product
Microsoft Access
Device & OS
not provided
Scenario
Automating email generation triggered by an Access command button, where multiple reports or documents need to be attached to the same email.
Observed behavior
The standard DoCmd.SendObject method currently implemented only allows for a single PDF attachment, preventing the user from attaching the second required PDF to the same email message.
Before you start

Ensure you have Microsoft Outlook installed and configured with an active email profile on your computer, as handling multiple attachments requires utilizing the Outlook application object via VBA.

Solution 1Recommended

Use Outlook Automation to Attach Multiple PDFs

Since DoCmd.SendObject is strictly limited to a single attachment, utilizing Outlook Automation allows you to create a custom email object and add as many attachments as needed.

Outlook Automation involves creating a link between MS Access and MS Outlook using VBA. By creating an Outlook Application object and generating a MailItem, you gain full control over the email's properties, including the ability to run the Attachments.Add method multiple times.

1
Open the VBA Editor

Press Alt + F11 while in Microsoft Access to open the Visual Basic for Applications (VBA) Editor.

2
Enable the Outlook Object Library Reference

In the top menu, click Tools and select References. Scroll down the list, check the box for Microsoft Outlook XX.X Object Library (where XX.X is your version number), and click OK.

3
Create the Outlook Application and MailItem Objects

In your command button's click event, define your variables: Dim objOutlook As Outlook.Application and Dim objMail As Outlook.MailItem. Then, instantiate them using Set objOutlook = New Outlook.Application and Set objMail = objOutlook.CreateItem(olMailItem).

4
Add the Multiple PDF Attachments

Use the Attachments.Add method on your objMail object for each PDF you want to include. For example, call objMail.Attachments.Add followed by the exact file path of your first PDF, and repeat the command on the next line for your second PDF.

5
Display or Send the Email

Set the email recipient using objMail.To and the subject using objMail.Subject. Finally, use objMail.Display to review the email before sending, or objMail.Send to dispatch it automatically.

Use Outlook Automation to Attach Multiple PDFs
Exporting Reports First: Remember to use DoCmd.OutputTo to export your Access reports as PDF files to a temporary folder on your drive before running the Attachments.Add method.
Free Microsoft Office alternative

Looking for a Lightweight, Macro-Enabled Office Suite?

While Microsoft Access handles complex databases, WPS Office offers a highly compatible, free alternative for your daily document, spreadsheet, and presentation needs. It supports advanced VBA macros in Spreadsheets, making data automation seamless without the heavy resource requirements.

  1. 1. Download the Installer: Visit the official WPS Office website and download the free installer for your operating system.
  2. 2. Open Your Existing Files: Launch WPS Office and seamlessly open your legacy Word documents, Excel spreadsheets, and PDFs without formatting loss.
  3. 3. Run VBA Macros: Access the Developer tab in WPS Spreadsheets to write, edit, and execute your macro scripts efficiently.
Seamless compatibility with Microsoft Excel (.xlsx, .xlsm), Word (.docx), and PowerPoint (.pptx) formats.Robust VBA macro support in WPS Spreadsheets for automating repetitive tasks and data processing.Built-in PDF editing tools for managing, merging, and extracting PDF attachments.Lightweight installation with a familiar, user-friendly tabbed interface.
microsoft office alternative - wps office

Frequently Asked Questions

Why does DoCmd.SendObject only allow one attachment?

The DoCmd.SendObject method is a legacy Access function designed for quick, simple messaging. It inherently limits output to a single database object or report per execution, making it impossible to append additional files natively.

Can I use Outlook Automation to send emails without user intervention?

Yes, you can automate the process entirely. By using the .Send method instead of .Display in your MailItem VBA code, the email will be routed directly to your Outlook Outbox without popping up on the screen.

How do I add the Outlook Object Library reference in MS Access?

Open the VBA Editor by pressing Alt + F11, click on Tools in the top menu, select References, scroll down the alphabetical list, and check the box next to Microsoft Outlook [Your Version] Object Library. Click OK to save.

Is it possible to attach non-PDF files using Outlook Automation?

Absolutely. The Attachments.Add method in Outlook Automation accepts valid file paths for any file type, including Excel spreadsheets, Word documents, images, and text files.