Send Email from MS Access Using VBA

VBA & macros · Updated November 3, 2026

Send Email from MS Access Using VBA

Yes. In Microsoft Access for Windows, VBA can create and send an email through classic Outlook automation, or open a message using Access’s built-in DoCmd.SendObject method. For a first version, create a message and display it for review before sending; this lets you verify recipients and content without accidentally emailing the wrong person.

How Access sends email

Access does not itself provide a general-purpose email delivery service. VBA hands the message to another component: commonly classic Outlook on the same Windows computer, or the default mail client through the Messaging Application Programming Interface (MAPI). A business application can instead connect to a service such as Microsoft Graph, usually through an approved application and authentication setup.

These choices are not interchangeable. Outlook automation gives VBA access to message properties, attachments, and Outlook’s send or display commands, but it depends on classic Outlook being installed and configured. DoCmd.SendObject is a short way to send or compose a message, often with an Access report attached. A service-based method can work without controlling Outlook, but typically takes more setup and requires suitable permissions.

Create an Outlook draft with VBA

The example below uses late binding: variables are declared as generic objects, so you do not have to add a reference to the Outlook Object Library in the VBA editor. It creates a plain-text message and displays it rather than sending it automatically. Replace the sample address and text before using it.

Public Sub CreateEmailDraft()
    Dim olApp As Object
    Dim olMail As Object

    On Error Resume Next
    ' Reuse Outlook if it is already running.
    Set olApp = GetObject(, "Outlook.Application")

    ' Start Outlook if it is not running.
    If olApp Is Nothing Then
        Set olApp = CreateObject("Outlook.Application")
    End If
    On Error GoTo ErrorHandler

    If olApp Is Nothing Then
        MsgBox "Classic Outlook could not be opened.", vbExclamation
        Exit Sub
    End If

    ' Create a message and leave it open for review.
    Set olMail = olApp.CreateItem(0)
    With olMail
        .To = "recipient@example.com"
        .Subject = "A message from Access"
        .Body = "Hello," & vbCrLf & vbCrLf & _
                "This message was prepared in Microsoft Access." & vbCrLf
        .Display
    End With

CleanUp:
    Set olMail = Nothing
    Set olApp = Nothing
    Exit Sub

ErrorHandler:
    MsgBox "The email could not be created: " & Err.Description, vbExclamation
    Resume CleanUp
End Sub

In Access, open the database, press Alt+F11 on Windows to open the Visual Basic Editor, choose Insert > Module, and paste the procedure into the module. Run it from the editor or call it from a form button’s On Click event. The code uses Outlook’s standard item type value 0 for a mail item. Late binding avoids a compile-time Outlook reference, but it does not remove the requirement for compatible Outlook software.

Before running any macro, save a separate copy of the database. VBA changes and sent email cannot be undone with Ctrl+Z. Start with .Display; after testing the message, an application may use .Send instead, but only when recipient and content checks are in place.

Use Access fields for recipients and message content

A useful next step is to replace fixed sample values with values from a form or a record. For example, a form button can read Me.txtEmail, Me.txtSubject, and Me.txtMessage and assign those values to the message’s .To, .Subject, and .Body properties. The names after Me. must match actual controls on the form. Check that the email field is not Null or blank before creating a message, and show a clear warning when required information is missing.

For a batch operation, use a query or recordset to select only the records that should receive a message. Avoid sending to every row in a table by default. A preview step, a small test group, and a logged status field can help catch bad addresses or duplicate runs. If recipients should not see one another’s addresses, use the BCC field or send individual messages rather than putting a group in To.

Add a report or file attachment

With Outlook automation, an attachment can be added to the message using .Attachments.Add and a full file path, such as a PDF stored in a known folder. Check that the file exists before adding it, and ensure the Access process has permission to read it. A path on a mapped drive may not be available when the database runs under a different Windows account or as a scheduled task.

Access also has a built-in option for emailing an Access object, commonly a report. DoCmd.SendObject can send a report in a supported output format or open a prepared message for review. For example, its arguments include the object type, object name, output format, recipient, subject, message text, and an edit-message setting. Consult Access VBA’s Object Browser or the method’s help for the exact argument order and formats supported by the installed Access version. This route is convenient for an Access report; Outlook automation is usually more flexible when you need to construct a custom message or add files.

Classic Outlook versus new Outlook

A common source of confusion is that “Outlook” now refers to more than one Windows application. The VBA example relies on Outlook’s COM automation interface, supported by classic Outlook for Windows. The new Outlook for Windows does not provide the same COM automation interface, so installing or opening new Outlook alone does not make this example work. If the code reports that it cannot create the Outlook application, check which Outlook version is installed and whether classic Outlook is available.

This is also a Windows-specific approach. Access for Mac is not available as a native desktop product, and Outlook COM automation is a Windows technology. A database used from a Mac or from a browser needs another design, such as an approved web service or a workflow running on a Windows machine.

Security, permissions, and reliable sending

Outlook may display a security warning or block programmatic access depending on the Outlook version, antivirus status, and organization policy. Do not disable security controls simply to make a macro run. Ask the organization’s Microsoft 365 or IT administrator which supported method is approved. In managed environments, Microsoft Graph or a controlled Power Automate workflow may be a better fit than automating a desktop mail client.

  • Validate addresses and required fields before creating or sending a message.
  • Keep a confirmation or review step for messages with important business consequences.
  • Limit automated sends to records selected by a clear query or user action.
  • Do not store passwords or access tokens directly in VBA code.
  • Record enough information to detect repeat sends, while following the organization’s data-retention rules.

Also consider what the database contains. Email can expose personal or confidential information, and sending a report to the wrong address can be difficult to reverse. Apply normal access controls to the Access file and use only recipient and attachment data that the sender is authorized to share.

Common errors and how to investigate them

If “ActiveX component can’t create object” appears at CreateObject, Access could not obtain the Outlook automation object. Confirm that classic Outlook is installed and set up, and that the code is running on Windows. If a reference-based example fails to compile but late-bound code works, the Outlook library reference may be missing or mismatched; late binding avoids that particular compile-time dependency.

If a message opens but does not send, check whether the code uses .Display rather than .Send, whether Outlook is signed in, and whether the message remains in the Outbox. A security prompt or organization policy may also require user action. If a field value is missing, inspect the form control or query result and handle Null values before assigning them to the message. Use VBA’s error handler to show the actual error description during development, rather than silently ignoring failures.

Choosing the right method

Use Outlook automation when the database runs on Windows with classic Outlook configured and users need to review messages, use their Outlook profile, or create custom messages and attachments. Use DoCmd.SendObject when the main task is emailing an Access object, particularly a report, with minimal custom code. For unattended workflows, many recipients, or a requirement to avoid a desktop Outlook dependency, investigate an organization-approved service such as Microsoft Graph or Power Automate. Those options require authentication, permissions, and often administrator involvement; they are not a one-line replacement for Outlook VBA.

Older examples sometimes recommend CDO or direct SMTP code. Do not assume those approaches will work with a current Microsoft 365 mailbox: authentication requirements and tenant settings matter, and basic username-and-password SMTP submission may be disabled. Choose an approach supported by the mail provider and the organization, rather than embedding mailbox credentials in an Access project.

Frequently Asked Questions

Can Access send an email without Outlook?
Yes, but not with the Outlook automation example. Access can use a configured MAPI client through methods such as DoCmd.SendObject, or a developer can connect to an approved email service such as Microsoft Graph. Each option has its own installation, authentication, and permission requirements.

Will this VBA work with new Outlook for Windows?
Not as written. It uses Outlook COM automation, which is associated with classic Outlook for Windows; new Outlook does not expose that same automation interface. Use a supported service or workflow if classic Outlook is unavailable.

How do I send an Access report by email?
Use DoCmd.SendObject with the report as the object and select an output format supported by Access. Set the recipient and message details, and use its edit-message option when you want the user to review the email before sending.

Can VBA send an email automatically without showing it?
With classic Outlook automation, .Send submits the message instead of displaying it. Add validation, authorization, and safeguards against duplicate sends first, and be aware that Outlook security settings or organizational policy can still affect programmatic sending.

Can I add multiple recipients or an attachment?
Yes. Outlook mail items provide recipient and attachment collections, and recipients can be assigned in the appropriate To, CC, or BCC fields. Validate addresses and file paths, and consider privacy and size limits before sending.

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.