Excel VBA: Send Emails Through Outlook Automatically

VBA & macros · Updated November 3, 2026

Excel VBA: Send Emails Through Outlook Automatically

Yes. Excel VBA can create and send email through Outlook on Windows by automating the classic Outlook desktop app. The usual method is to create an Outlook mail item, fill in its recipients and content, then display it for review or send it from the macro.

How Excel and Outlook work together

Excel does not send the message itself in this approach. VBA asks Outlook’s Object Model to create and handle an email, using Windows COM automation. Outlook supplies the account, profile, and mail transport, so the computer needs a configured Outlook profile and a version of the desktop app that supports this automation.

This is useful for tasks such as sending a report, creating reminders from a worksheet, or preparing messages for a list of contacts. It does not mean Excel can bypass Outlook setup, your organization’s policies, or the recipient’s email protections. A macro can also send the wrong content quickly if the workbook data or code is wrong, so start with a review step.

What to set up before running a macro

  • Use Excel for Microsoft 365 on Windows and have classic Outlook desktop installed and configured with an account.
  • Save the workbook as an Excel Macro-Enabled Workbook (.xlsm). A standard .xlsx file cannot store VBA code.
  • Open the VBA editor from Developer > Visual Basic. If the Developer tab is hidden, enable it through File > Options > Customize Ribbon.
  • In the VBA editor, choose Insert > Module, then paste the macro into the module.
  • Save a copy of the workbook before running the macro. Macros cannot be undone with Ctrl+Z.

Excel may block macros depending on your security settings. Use code only from a source you trust; do not lower macro protections globally just to run an unfamiliar workbook. On a Mac, VBA is available in Excel, but this Windows COM method for controlling Outlook is not supported in the same way.

A simple Outlook email macro

This example creates a message and opens it for review rather than sending it immediately. Replace the sample address and text before use. When you have checked the message and want the macro to send it automatically, replace the display instruction with the send instruction.

Sub CreateOutlookEmail()
    Dim olApp As Object
    Dim mail As Object

    On Error GoTo ErrHandler

    ' Create or connect to the Outlook desktop application.
    Set olApp = CreateObject("Outlook.Application")
    Set mail = olApp.CreateItem(0)

    With mail
        .To = "recipient@example.com"
        .Subject = "Weekly status"
        .Body = "Hello," & vbCrLf & vbCrLf & _
                "Here is the weekly status update."
        .Display
    End With

    Set mail = Nothing
    Set olApp = Nothing
    Exit Sub

ErrHandler:
    MsgBox "Could not create the Outlook message: " & _
           Err.Description, vbExclamation
    Set mail = Nothing
    Set olApp = Nothing
End Sub

The argument value zero creates a mail item. The variables are declared as Object so the macro uses late binding; in the usual case, that avoids needing to set an Outlook library reference in Tools > References. The error handler reports a failure, for example if Outlook cannot be started or the profile is unavailable. It does not guarantee that a message has been delivered.

Personalizing the message and adding files

For plain text, the Body property is straightforward. For formatting, a macro can set HTMLBody to an HTML string, but the markup must be valid and any data inserted into it should be handled carefully. For example, a name containing an ampersand or angle bracket can affect HTML rendering if it is inserted without encoding. A simple email generally does not need HTML formatting.

To attach a file, the macro can use Outlook’s Attachments collection and provide a full file path. Check that the file exists before adding it, and make sure the attachment is the intended one. A path built from a worksheet cell can point to the wrong file if someone edits the cell or moves a folder. Be especially cautious with confidential documents and with links or files that leave your organization.

Recipient fields can include To, CC, and BCC addresses. Multiple addresses are commonly separated with semicolons, but test the format with your Outlook setup and confirm the recipients in the draft. Do not assume that a worksheet column is clean: blank cells, misspelled addresses, duplicate entries, or pasted spaces can cause errors or unwanted messages.

Sending messages from worksheet rows

A common next step is to read a recipient and message details from each worksheet row. A typical layout might put email addresses in column A, names in column B, and a status value in column C, with row 1 reserved for headings. A loop can start at row 2, check that the address is present, build one message, and record whether that row was processed.

Before automating a batch, test with a small set of rows and addresses you control. Decide what should happen when a row is incomplete: skip it and record a reason, or stop and ask for correction. If the macro is run twice, it may send duplicates unless it checks a status column or another reliable record. Marking a row as sent only after the send call succeeds can help, but it is not a delivery receipt; messages can still be delayed, rejected, or filtered later.

For personalized messages, replace a placeholder in the body with the name from the current row, and review edge cases such as blank names or punctuation. A preview-first workflow is safer for a new template. If every message uses the same attachment, confirm that it is appropriate for every recipient; sending one person’s information to another is a serious data-handling mistake.

Display first or send automatically?

Displaying a message creates an Outlook window for a person to inspect and send manually. This is usually the better choice while building or testing a macro, because it exposes incorrect recipients, awkward formatting, and missing attachments before the message leaves the outbox.

Sending from code is appropriate only when the process is understood and the data has been checked. It can submit messages without giving the user a final opportunity to review each one. In particular, do not use automatic sending as a substitute for validating a distribution list or confirming that a workbook contains current information. For recurring jobs, include a clear confirmation step, a test mode, or a limit on the number of rows processed during initial runs.

Outlook version and platform compatibility

The code above targets classic Outlook desktop on Windows, which exposes the Outlook Object Model for COM automation. The new Outlook for Windows does not support this traditional COM automation approach, so installing or switching to new Outlook does not make this macro equivalent to one that controls classic Outlook. If the macro reports that the class is not registered or cannot create the Outlook application, first check which Outlook app is installed and whether a desktop profile is configured.

Excel for the web cannot run VBA macros. Excel for Mac can run VBA, but the Windows COM calls shown here are not a cross-platform solution for Outlook for Mac. Mac automation requires a different approach and can depend on the Mac apps and permissions available. If a workbook must work on both Windows and Mac, design separate platform-specific workflows or use a service-based solution rather than assuming this code will transfer unchanged.

Common failures and practical fixes

  • Outlook will not start: Open Outlook manually, confirm that an account is configured, and check whether your organization allows desktop automation. Restarting Excel and Outlook may help after a profile or update change.
  • The macro is blocked: Check the workbook’s macro security status and follow your organization’s trusted-file process. Do not enable all macros for every workbook.
  • The message appears but does not arrive: A successful display or send action is not proof of delivery. Check Outlook’s Outbox and Sent Items, connection status, server messages, and junk or quarantine handling.
  • Recipients are wrong or missing: Inspect the exact cell values, remove unintended spaces, and test a small sample. Confirm that formulas in the source cells have recalculated before sending.
  • Attachments fail: Verify the complete path, file permissions, and file availability. An attachment path that works on one person’s computer may not exist on another computer.

Some environments show a security notice or block programmatic sending, depending on Outlook version, security software, and organizational policy. Avoid trying to defeat those controls. Ask the organization’s Microsoft 365 administrator about an approved method if automation is restricted.

Security and responsible use

Email macros can transmit personal, financial, or business information outside the workbook. Limit the macro to necessary recipients, avoid storing passwords in VBA, and do not include sensitive data in a message unless your organization permits that channel. A macro project can be inspected or altered, so VBA should not be treated as a secure place for secrets.

Keep a tested copy of the workbook and use a small controlled test before a real send. For a workbook shared with others, document the expected columns, what the macro sends, and how to stop it. A confirmation prompt can reduce accidental runs, but it cannot replace checking the message and recipient data.

Alternatives to Outlook VBA

If the task is occasional, composing the message in Outlook manually or using Excel’s built-in sharing options may be simpler. For repeatable approvals and notifications, Power Automate can run a cloud flow triggered by a schedule, form, or supported data source, subject to the connectors and permissions available in your Microsoft 365 plan. This avoids relying on a particular desktop session, though it still needs configuration and governance.

Organizations with a larger or more controlled sending process may use Microsoft Graph or an approved application service. These approaches require appropriate authentication and permissions and may need administrator involvement. They are not drop-in replacements for a short VBA macro, but they can be more suitable for unattended, centrally managed workflows.

Frequently Asked Questions

Can Excel VBA send an email without opening Outlook?
With the Outlook Object Model method described here, Outlook desktop is the sending application and must be available and configured. Other services can send mail through APIs, but they use different setup, authentication, and permissions.

Does the macro send the message automatically?
The sample opens a draft for review. A macro can be set to send without displaying the draft, but that removes the final manual check. Test with controlled recipients before using automatic sending.

Can I send an email from Excel for the web?
No. Excel for the web does not run VBA macros. Use desktop Excel or choose a supported workflow such as Power Automate for a browser-based process.

Will this code work with the new Outlook for Windows?
Not through the classic Outlook COM automation method shown. It is intended for classic Outlook desktop on Windows; the new Outlook does not provide that traditional automation interface.

Can a macro send different messages to different rows?
Yes. VBA can read each row’s recipient and other fields, then create a separate message for that row. Validate the data, prevent duplicate processing, and test a small batch before sending to a full list.

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.