You can use Excel VBA to automatically open a new Outlook email message with optional pre-filled fields like recipient, subject, and body. This is useful for automating reports, notifications, or data sharing directly from a spreadsheet. No additional tools are needed beyond Microsoft Excel and Outlook being installed and configured on the same Windows machine.

What You'll Need

  • Microsoft Excel (2010 or later, including Microsoft 365)
  • Microsoft Outlook (same version or compatible with Excel)
  • A Windows operating system (this method does not work on Excel for Mac)
  • Basic access to the VBA editor in Excel (Developer tab enabled or via Alt+F11)

Step-by-Step

  1. Open your Excel workbook and press Alt + F11 to launch the VBA Editor.
  2. In the VBA Editor, click Insert on the menu bar, then select Module to create a new code module.
  3. In the module window, paste the following VBA code:
  4. Sub SendOutlookMail()
        Dim OutApp As Object
        Dim OutMail As Object
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
        
        With OutMail
          .To = "recipient@example.com"
          .CC = ""
          .BCC = ""
          .Subject = "Report from Excel - " & Format(Date, "yyyy-mm-dd")
          .Body = "Hello,\n\nPlease find the latest data attached.\n\nBest regards,\n" & Application.UserName
          .Display  'Use .Send to send automatically, or .Display to review first
        End With
        
        Set OutMail = Nothing
        Set OutApp = Nothing
      End Sub
  5. Customize the code as needed:
    • Change the .To field to the desired email address.
    • Modify the .Subject line to include dynamic content from cells (e.g., & Range("A1").Value).
    • Edit the .Body text or build it using cell values.
    • To attach the active workbook, add .Attachments.Add ActiveWorkbook.FullName before .Display.
  6. Close the VBA Editor and return to Excel.
  7. Press Alt + F8, select SendOutlookMail from the list, and click Run.
  8. A new Outlook email window will appear with the specified fields filled in. Review and send manually, or change .Display to .Send for automatic sending (use with caution).

Common Mistakes

  • Forgetting to enable macro security settings: If macros are disabled, the code won’t run. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings and enable macros for trusted locations or digitally signed VBA projects.
  • Using .Send during testing: This sends the email immediately without review. Always test with .Display first to avoid accidental sends.
  • Referencing Outlook objects without proper late binding: Using early binding (Dim OutApp As Outlook.Application) requires setting a reference to the Outlook library via Tools > References in the VBA editor. If skipped, it causes compile errors. The example uses late binding (As Object) to avoid this need.
  • Running the code on Excel for Mac: Outlook automation via VBA is not supported in the Mac version of Excel due to sandboxing and lack of COM access.
  • Not handling errors: If Outlook is not installed or not running, the code will fail. Add error handling (On Error Resume Next or Try...Catch-style logic) for robustness in production use.

Tips

  • Use cell values to personalize emails: Replace static text with references like .To = Range("B2").Value or .Subject = "Update for " & Range("C5").Value.
  • Loop through a list of recipients: Place email addresses in a column and use a For Each loop to send individualized messages.
  • Add HTML formatting: Use .HTMLBody instead of .Body to include bold text, colors, or tables. Example: .HTMLBody = "

    Hello,

    See the report below.

    "
  • Save drafts instead of sending: Use .Save to store the email in the Drafts folder for later review.
  • Log sent emails: Write a timestamp or recipient to a hidden sheet after each email is created to maintain an audit trail.

Troubleshooting

  • Nothing happens when I run the macro:
    • Check that macros are enabled. Look for a security warning banner above the formula bar when opening the workbook.
    • Press Alt + F11, go to Debug > Compile VBAProject to check for syntax errors.
    • Ensure you’re running the macro from the correct workbook and module.
  • Error: "ActiveX component can't create object" (Error 429):
    • This means Outlook is not installed or not accessible. Verify Outlook is installed and you can open it manually.
    • If using 64-bit Excel, ensure you have a 64-bit version of Outlook installed (or vice versa). Bitness must match.
    • Repair Office installation via Control Panel > Programs > Microsoft Office > Change > Quick Repair.
  • Email sends but attachments are missing:
    • Confirm the file path is correct when using .Attachments.Add. Use ActiveWorkbook.FullName for the current file.
    • If the workbook hasn’t been saved, FullName may return a temporary path. Save the workbook first with ThisWorkbook.Save.
  • Runtime error '91': Object variable or With block variable not set:
    • This usually occurs if CreateObject("Outlook.Application") fails. Ensure Outlook is installed and not blocked by group policy.
    • Add On Error Resume Next before the CreateObject line and check if OutApp is Nothing afterward.

Frequently Asked Questions

Can I send the email automatically without seeing it?

Yes, replace .Display with .Send in the code. However, use this only after thorough testing, as it sends the email immediately without user confirmation.

Do I need to install anything extra to make this work?

No additional installation is required if Microsoft Outlook is already installed and configured on the same Windows computer as Excel. The VBA code uses Outlook’s COM interface, which is included with a standard Office installation.

Will this work in Excel for Mac or Excel Online?

No. This method relies on Windows-specific COM automation and does not function in Excel for Mac, Excel Online, or mobile versions of Excel due to platform restrictions and lack of Outlook object model access.

How do I include data from Excel cells in the email body?

Concatenate cell values into the .Body or .HTMLBody string. For example: .Body = "The total is " & Range("B10").Value & "." Use vbNewLine or & Chr(10) & for line breaks.

Is it safe to use .Send in production code?

Only if you have validated the recipient list, subject, and body content. Consider adding a confirmation MsgBox or logging step before sending to reduce the risk of unintended emails.

Can I attach multiple files or the active worksheet as a PDF?

Yes. Use .Attachments.Add multiple times for different files. To attach a worksheet as PDF, you’d need to export it first using ExportAsFixedFormat, then attach the resulting file — this requires additional VBA code beyond the basic email launch.