Yes. In Excel for Microsoft 365 on Windows, VBA can create and send an email through the classic Outlook desktop app using Outlook’s COM automation interface. The example below opens a draft for review; after confirming it works, you can change one line to send it directly. This method does not work with new Outlook for Windows or Outlook on the web.
How Excel VBA and Outlook work together
Excel VBA does not send a message by itself in this approach. Instead, the macro asks the classic Outlook desktop application to create an email, fills in its fields, and either displays the message or submits it for sending. Outlook then uses an account and profile configured in Outlook. The sender, delivery process, and any account-level policies are therefore determined by that Outlook setup, not by the workbook alone.
The automation interface is called the Outlook Object Model. Excel can connect to an existing Outlook session or start Outlook, create a MailItem, and set properties such as To, Subject, and Body. This is useful for routine messages based on spreadsheet data, such as sending a status report or preparing a personalized reminder. It is not the same as emailing directly from Excel’s browser version or using a web-based Outlook mailbox through a web page.
“Outlook 365” can refer to a Microsoft 365 subscription, while the installed Outlook app may be either classic Outlook or new Outlook. The distinction matters: this VBA example requires classic Outlook for Windows, which exposes the COM object model. New Outlook for Windows does not expose that interface for this automation, and Outlook on the web cannot run the macro.
What you need before running a macro
Use Excel desktop for Windows, classic Outlook for Windows, and an Outlook profile with an account configured. Outlook may need to be opened and signed in at least once so its profile is ready. Excel for the web cannot run VBA. Excel for Mac also cannot use Windows COM automation, so the code below is not a cross-platform solution; Outlook for Mac does not provide the same COM interface.
To enter the code in Windows Excel, open the workbook and choose Developer > Visual Basic. In the editor, choose Insert > Module, then paste the procedure into the new module. If the Developer tab is not visible, enable it through File > Options > Customize Ribbon and select Developer. Save the workbook as an Excel Macro-Enabled Workbook (*.xlsm) if it needs to retain the macro.
Excel’s macro security settings may prevent a procedure from running. Review File > Options > Trust Center > Trust Center Settings > Macro Settings, and follow your organization’s policy. Do not enable all macros indiscriminately; a macro can perform actions beyond sending email. A trusted, controlled workbook or a digitally signed macro is safer than lowering security for every file.
A basic macro that creates an Outlook draft
This example uses late binding: the Outlook variables are declared as Object, so you do not need to select an Outlook reference in the Visual Basic Editor. It creates a new message and displays it for inspection rather than sending it immediately.
Sub CreateOutlookDraft()
Dim outlookApp As Object
Dim mailItem As Object
' Connect to Outlook if it is already open; otherwise try to start it.
On Error Resume Next
Set outlookApp = GetObject(, "Outlook.Application")
If outlookApp Is Nothing Then
Set outlookApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0
If outlookApp Is Nothing Then
MsgBox "Classic Outlook could not be opened. Check that it is installed and configured."
Exit Sub
End If
' Create a message and show it for review.
Set mailItem = outlookApp.CreateItem(0)
With mailItem
.To = "recipient@example.com"
.CC = ""
.Subject = "Monthly status update"
.Body = "Hello," & vbCrLf & vbCrLf & _
"Please see the latest status update." & vbCrLf & vbCrLf & _
"Regards"
.Display
End With
Set mailItem = Nothing
Set outlookApp = Nothing
End Sub
Replace the sample address, subject, and message with your own content. The numeric value 0 passed to CreateItem identifies a standard mail item. The body shown here is plain text, and vbCrLf adds line breaks. Because the macro uses .Display, Outlook opens the message window and leaves the final decision to you. Save a copy of the workbook before running any macro: VBA changes and actions cannot be undone with Ctrl+Z.
How to send the message instead of displaying it
After checking the draft version, replace the line .Display with .Send. The Send method submits the message through Outlook; it does not mean the recipient has already received or read it. Delivery can still depend on connectivity, server processing, recipient address validity, spam filtering, and your organization’s rules. For a first run, test with your own address and keep the message visible until its contents and recipients are verified.
A macro that sends without displaying a draft is easier to run unattended, but it also makes mistakes easier to distribute. A typo in a recipient cell, a blank subject, or an accidental repeat of the macro can generate real messages. Consider adding checks for required fields and a confirmation prompt before sending. For example, stop if the recipient is blank, and show the number of messages about to be sent before processing a list.
Outlook may show a security warning when a program tries to send email, depending on the Outlook version, security configuration, and antivirus status. Do not assume a warning will always appear or that it is safe to bypass one. If your organization manages Outlook security, ask its Microsoft 365 or IT administrator about the approved method for automated mail.
Using cells to personalize messages
A common next step is to build each message from a row in a worksheet. For example, a sheet might have a recipient address in column A, a customer name in column B, and a due date in column C, with headers in row 1. The macro can read a row’s values and assign them to the mail item’s To, Subject, or Body properties. This is useful for preparing individualized drafts, but it is important to validate the data before sending.
For a mailing list, first create drafts for a small sample of rows and inspect them. Check that the address is present, the greeting uses the intended name, and dates or amounts appear in the expected format. Cells that look empty may contain spaces or formulas returning an empty string, so a macro should account for those cases. Also decide how the procedure should handle duplicate addresses, invalid addresses, and rows marked as already processed.
Keep a status column, such as “Draft created” or “Sent,” if the workflow needs an audit trail. Update that status only after the corresponding action succeeds, and consider recording a timestamp. Avoid storing sensitive information in a workbook unless access is appropriately restricted. A worksheet-based process is convenient for small, controlled tasks, but it should not be treated as a bulk-email platform with built-in unsubscribe handling, campaign reporting, or compliance controls.
Attachments, formatting, and sender accounts
To attach a file, add an Attachments.Add call to the With mailItem block before .Display or .Send. For instance, .Attachments.Add "C:\Reports\summary.pdf" attaches that file if the path is valid and accessible. A path that exists on your computer may not exist for another user running the workbook, so shared workflows should use a stable, accessible location. Check that the attachment is the intended file before sending, especially when a macro constructs the path from cell values.
The .Body property creates plain-text content. For formatted HTML, code can assign a string to .HTMLBody instead; HTML markup must be valid and any text inserted from cells should be handled carefully. HTML formatting is not a guarantee that every email program will display the message identically. A plain-text body is often simpler for short notifications and avoids layout differences.
By default, Outlook uses the account associated with the active profile and its sending rules. If the user has multiple accounts, the default sender may not be the one intended. Shared mailboxes and alternate From addresses can also require account configuration and send permissions. Confirm the sender shown in the draft; do not assume that the recipient, workbook owner, and sending account are automatically the same person.
Common problems and practical fixes
- Outlook could not be opened: Check that classic Outlook for Windows is installed, that an account profile is configured, and that the macro is not being run from Excel for the web. New Outlook is not a substitute for the COM interface required by this code.
- “User-defined type not defined” appears: The sample uses late binding and should not require an Outlook reference. If you changed a variable declaration to an Outlook-specific type, either restore Object declarations or select the appropriate Outlook Object Library under Tools > References in the VBA editor. Library names can vary by installed Outlook version.
- The macro runs but the message is not sent: Check whether the code still uses .Display, whether Outlook is online, and whether the message is waiting in Outbox. Inspect any error message and confirm the account can send messages manually.
- An address or attachment is missing: Verify the exact cell value or file path at the moment the macro runs. For a file, confirm that the file exists and that the current user has permission to read it.
- A security prompt appears: This can be controlled by Outlook security policy and system configuration. Follow your organization’s approved process rather than attempting to disable protections to make the macro run silently.
When troubleshooting, make one change at a time and test with a draft or your own address. If Excel and Outlook have different privilege levels—for example, one is running as an administrator and the other is not—Windows automation can also fail. Normally, run both applications under the same user account and at the same privilege level.
When to use another method
Excel VBA with classic Outlook is a practical choice when a person is reviewing messages generated from a workbook on a Windows computer. It is less suitable for an unattended service, a workflow that must work on Mac and Windows, or high-volume customer campaigns. It depends on desktop Outlook being available and on a user profile, and a workbook macro is not a managed email-delivery system.
For Microsoft 365 workflows that need to run online or without a desktop Outlook session, consider Power Automate or an application built with Microsoft Graph. These approaches have different setup, permissions, licensing, and administrator-consent requirements; they are not drop-in replacements for a VBA macro. A mail-merge feature may also fit personalized messages, depending on the data source and the required review process. Choose based on whether you need manual approval, cross-platform operation, reliable automation, or centralized administration.
Frequently Asked Questions
Can Excel VBA send email through new Outlook?
No, this sample uses classic Outlook’s COM object model, which new Outlook for Windows does not expose. Use classic Outlook or choose an approved alternative such as Power Automate or Microsoft Graph.
Can I send Outlook email from Excel for the web?
No. Excel for the web can open and edit many workbooks, but it cannot run VBA macros. Open the macro-enabled workbook in Excel desktop on Windows to use this Outlook automation method.
Do I need to reference the Outlook library?
Not for the sample shown, because it uses late binding and declares Outlook objects as Object. Early binding is another option, but it requires selecting an Outlook Object Library reference and may need adjustment on computers with different installed versions.
Can the macro send email without opening Outlook?
The code relies on the classic Outlook application and its configured profile; it is not a direct connection from Excel to a mailbox. Outlook may start in the background when the macro creates the application object, but account setup and policies still apply.
Can VBA send an email with an attachment?
Yes. Add the file with the MailItem Attachments.Add method before displaying or sending the message. Use a verified file path and test with a draft so you can confirm the correct document is attached.
Related
- Excel Slicer Tutorial: Add, Format, and Connect Filters
- Excel Slicer Search Box: How to Find Items
- Excel Slicer Examples for PivotTables and Tables Explained
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA: Insert the Current Date and Time in a CellTo insert a fixed date-and-time timestamp with Excel VBA, assign the VBA function Now to a cell, then…
- Move a Picture in an Excel UserForm with the MouseTo move a picture around an Excel UserForm with the mouse, handle the Image control’s MouseDown and MouseMove…
- Excel VBA Like Operator: Pattern Matching ExplainedYes. In Excel VBA, the Like operator compares a string with a pattern, letting you test for text…
- Zoho Sheet VBA: How to Delete the Selected Row in ExcelZoho Sheet does not run Excel VBA macros, so there is no VBA command you can paste into…
- VBA Error Handling: On Error, Cleanup, and Debugging TipsVBA error handling lets a macro respond when a statement fails instead of stopping unexpectedly. Use On Error…
- How to Turn On Excel’s Macro Recorder in Microsoft 365In Excel for Microsoft 365 on Windows, select Developer > Code > Record Macro, set the macro’s name…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.