MS Access VBA: How to Send Email Safely

VBA & macros · Updated November 18, 2026

Yes. Microsoft Access VBA can send email with DoCmd.SendObject for an Access report or other database object, or automate classic Outlook when you need more control, such as attaching an arbitrary file. The right method depends on what you are sending and which mail client is installed; test with a draft before allowing a macro to send messages automatically.

How Access email sending works

Access does not send mail directly from a VBA procedure to an email server by itself. Instead, common approaches hand a message to another component: DoCmd.SendObject uses the computer’s configured mail setup, while Outlook automation asks the classic Outlook desktop application to create and send a message. Both methods need an appropriate mail account and client configuration to complete delivery.

This distinction matters when diagnosing problems. A VBA command can create or hand off a message without proving that the recipient’s server accepted it, that it avoided a junk folder, or that the recipient read it. Delivery status, account rules, network access, and organizational security controls remain outside Access.

These techniques apply to desktop Access. They are not a way to run VBA from an Access web app or a browser. Your organization may also restrict macros, automated sending, or particular mail clients through policy.

Use DoCmd.SendObject for Access reports

DoCmd.SendObject is usually the simplest choice when the message should contain an Access object, such as a report exported as a PDF. It can address the message, set its subject and body, and either show it for review or send it immediately. This example assumes a form named frmDashboard has a text box named txtEmail, and the database contains a report named rptMonthly.

Public Sub EmailMonthlyReport()
    Dim recipient As String
    Dim subjectText As String

    ' Read the recipient from the open form.
    recipient = Nz(Forms!frmDashboard!txtEmail, "")
    If Len(Trim$(recipient)) = 0 Then
        MsgBox "Enter a recipient email address first."
        Exit Sub
    End If

    subjectText = "Monthly report"

    ' True opens the message for review instead of sending it immediately.
    DoCmd.SendObject ObjectType:=acSendReport, _
        ObjectName:="rptMonthly", OutputFormat:=acFormatPDF, _
        To:=recipient, Subject:=subjectText, _
        MessageText:="The monthly report is attached.", _
        EditMessage:=True
End Sub

With EditMessage:=True, the email is displayed so a person can inspect it and click Send. After testing, you can set this argument to False to request immediate sending. That change removes a useful review step, so validate recipients and report contents first. The method’s attachment is the Access object being sent in the selected output format; it is not a general-purpose parameter for attaching any file path.

Use Outlook automation for other attachments

When the email needs a file that is not an Access object—for example, a PDF created elsewhere—VBA can automate classic Outlook for Windows. The following late-bound example creates a message, adds a file from the database folder, and sends it. Late binding avoids setting an Outlook reference in the VBA editor, though it does not remove the requirement for compatible Outlook software.

Public Sub EmailExistingPdf()
    Dim outlookApp As Object
    Dim mailItem As Object
    Dim attachmentPath As String

    On Error GoTo ErrHandler

    ' The PDF must already exist beside the Access database.
    attachmentPath = CurrentProject.Path & "\MonthlyReport.pdf"
    If Len(Dir$(attachmentPath)) = 0 Then
        MsgBox "The PDF file was not found: " & attachmentPath
        Exit Sub
    End If

    Set outlookApp = CreateObject("Outlook.Application")
    Set mailItem = outlookApp.CreateItem(0) ' 0 is an Outlook mail item.

    With mailItem
        .To = "recipient@example.com"
        .Subject = "Monthly report"
        .Body = "The monthly report is attached."
        .Attachments.Add attachmentPath
        .Send
    End With

CleanExit:
    Set mailItem = Nothing
    Set outlookApp = Nothing
    Exit Sub

ErrHandler:
    MsgBox "The email could not be sent: " & Err.Description
    Resume CleanExit
End Sub

To inspect the result before sending, replace .Send with .Display. The example uses a fixed recipient to make the code easy to read; a production database should obtain and validate the address from an appropriate form or record. A successful call to .Send means Outlook accepted the send request, not that delivery is guaranteed.

Choose the method that fits the job

For a report or other Access object, start with DoCmd.SendObject. It takes fewer moving parts and is convenient for a user-initiated report email. For an existing file, multiple attachments, or more detailed message customization, Outlook automation is generally more flexible. Consider who or what must perform the send as well: both approaches are easiest when a user is signed in on a desktop with a configured mail client.

  • One report, reviewed by a person: use DoCmd.SendObject with EditMessage:=True.
  • Attach a file by its path: use Outlook automation and check that the file exists before adding it.
  • Automatic or scheduled sending: assess whether a desktop mail client is dependable in that environment; a server-side workflow or supported mail service may be a better fit.
  • Need a preview or user edits: display the message rather than sending it immediately.

There is no universal rule that one method is always safer or more reliable. The right choice depends on the recipient source, attachment type, review requirements, installed software, and IT policy. Keep the message content and recipient selection separate from the send action where possible, so they can be checked before a message leaves the database.

Outlook version and configuration limits

Outlook automation through CreateObject("Outlook.Application") is designed for classic Outlook for Windows. Microsoft’s new Outlook for Windows does not provide the same Outlook Object Model COM automation interface, so code written for classic Outlook may fail when only the new Outlook is available. Do not assume that installing a mail app with “Outlook” in its name makes it compatible with VBA automation.

DoCmd.SendObject follows a different route through the configured mail integration, so its behavior depends on the Windows mail setup and the applications installed. Compatibility can vary with client and organizational configuration. If the command opens an unexpected program, does nothing, or reports that no mail client is available, confirm the default mail configuration and test on the actual computers that will run the database.

Outlook automation is Windows-specific in this example. Access for Mac is not a current desktop Access platform, and the shown Outlook COM code should not be treated as cross-platform VBA. If users have different computer setups, choose and test a supported workflow for each environment rather than assuming the same automation works everywhere.

Security, consent, and safe testing

Sending mail from a database can expose confidential records or distribute a report to the wrong person. A macro that sends immediately can also repeat messages if a user runs it twice or a process retries after an error. Start by sending to a test mailbox, use sample or non-sensitive data, and keep the message displayed until the recipient lookup and attachment logic have been verified.

  • Validate that the address is present and comes from the intended record; do not rely only on a text box being nonempty.
  • Check that the attachment exists, has the expected contents, and is appropriate to share before sending.
  • Use a confirmation step or a review window for user-triggered messages, especially during development.
  • Limit who can edit and run the database, and follow your organization’s rules for macros, data handling, and external email.
  • Log useful details such as the record identifier and send time when business processes require an audit trail, while avoiding unnecessary sensitive message data in logs.

Access VBA macros cannot be undone with Ctrl+Z after they run. Save a separate copy of the database before changing or running a new macro, and test against a copy of the data where practical. Use trusted locations or approved digital-signature practices only in line with your organization’s security policy; do not lower macro security settings simply to make an unverified database run.

Common problems and what to check

If DoCmd.SendObject reports that it cannot send the message, first determine whether a default mail client is configured and whether the user can send an ordinary message from that client. If a message appears but the attachment is missing, confirm that the object name is correct and that the chosen output format is supported for that object. A report name must identify a report in the database, and a report should be checked for the right records before it is emailed.

If Outlook automation raises an error at CreateObject, classic Outlook may be absent, unavailable, or blocked by the environment. If the error occurs at Attachments.Add, verify the complete path and file permissions; a file created later in the process cannot be attached before it exists. If the code runs but the message is not delivered, inspect Outlook’s Outbox, account status, and any organizational restrictions rather than assuming the VBA call confirms delivery.

Prompts or warnings can also arise from Outlook security settings, antivirus software, or administrator-managed policies. Their exact behavior depends on the Office and security configuration. Avoid code or registry changes intended to bypass such controls; ask the administrator about an approved automation method. For diagnosis, temporarily use .Display or EditMessage:=True and check the resolved To field, subject, body, and attachment before sending.

Alternatives for unattended workflows

Desktop automation is a poor fit for some unattended jobs. It can depend on a signed-in Windows session, an available profile, a compatible client, and permissions that may change. If a database must send scheduled messages while no user is logged in, discuss a supported service-based design with the organization’s IT team. Options may include a Power Automate flow, a Microsoft Graph-based application, or another approved mail service, depending on licensing, tenant policy, and the system that will run the process.

These alternatives are not automatic drop-in replacements for a VBA command. They require their own authentication, permissions, configuration, and error handling. Avoid embedding account passwords or secret keys in an Access database: database files can be copied, and credentials stored in code are difficult to protect. Select a service based on the organization’s approved identity and data-security practices.

Frequently Asked Questions

Can Access VBA send an email without opening Outlook?
Sometimes a configured mail integration can hand off a message without showing a compose window, and Outlook automation can call .Send. That does not mean Access independently sends through an email server, nor does it guarantee delivery. For unattended sending, verify that the chosen client or service supports the required setup.

Can DoCmd.SendObject attach a PDF?
Yes, it can send an Access report in PDF format by using acSendReport and acFormatPDF. It does not provide a general file-path argument for an arbitrary PDF. Use Outlook automation or an approved service when the PDF already exists as a separate file.

Can Access send email to several people?
Yes. The To, Cc, and Bcc fields can contain recipient lists in a format accepted by the mail client, commonly addresses separated by semicolons. Validate each address and consider privacy: use Bcc when recipients should not see one another’s addresses.

Why does Access VBA say Outlook is unavailable?
The Outlook COM automation example requires compatible classic Outlook for Windows. It may fail if classic Outlook is not installed or available, if only new Outlook is being used, or if a policy blocks automation. Check the installed client and ask IT about supported options.

Does a successful VBA send prove the email arrived?
No. It usually indicates that the application accepted or handed off the send request. Mail-server rejection, filtering, an incorrect address, or a recipient’s junk-mail rules can still prevent delivery. For important messages, use an approved tracking or confirmation process rather than treating the VBA result as proof of receipt.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.