To send an email from Excel using Outlook, you must use a VBA (Visual Basic for Applications) macro that creates an Outlook Application object and a MailItem object. This allows Excel to push data—such as cell values, reports, or attachments—directly into a new Outlook message, which can then be displayed for review or sent automatically. This process requires both Microsoft Excel and the desktop version of Microsoft Outlook to be installed and configured on the same computer.

What You'll Need

  • Microsoft Excel (Desktop version)
  • Microsoft Outlook (Desktop version, signed into an active account)
  • The Developer tab enabled in the Excel Ribbon
  • Basic access to the VBA Editor (Alt + F11)

Step-by-Step

  1. Enable the Developer Tab: By default, the tools needed for macros are hidden. Right-click any existing tab on the Ribbon (like Home or Insert) and select Customize the Ribbon. In the right-hand column, find the checkbox for Developer and check it. Click OK. Note that labels may differ slightly depending on your version of Office.
  2. Open the VBA Editor: Click the Developer tab and select Visual Basic, or press Alt + F11 on your keyboard. This opens a separate window where your code will live.
  3. Insert a New Module: In the VBA Editor, go to the top menu and select Insert > Module. This creates a blank white space where you can write your macro. It is better to put the code in a module rather than a specific sheet object so the macro can be called from anywhere in the workbook.
  4. Reference the Outlook Object Library: To ensure Excel understands Outlook commands, you need to enable the library. In the VBA Editor menu, go to Tools > References. Scroll down until you find Microsoft Outlook XX.X Object Library (the version number depends on your Office installation). Check the box and click OK.
  5. Write the Macro Code: Copy and paste the following code into the module window. This example is designed to send a simple email using values from a spreadsheet.
    Sub SendOutlookEmail()
        Dim OutApp As Outlook.Application
        Dim OutMail As Outlook.MailItem
        
        ' Create the Outlook session
        Set OutApp = New Outlook.Application
        Set OutMail = OutApp.CreateItem(olMailItem)
    
        On Error Resume Next
        With OutMail
            .To = "recipient@example.com"
            .CC = "manager@example.com"
            .BCC = ""
            .Subject = "Automated Report from Excel"
            .Body = "Hello, please find the requested data attached or listed in this email."
            '.Attachments.Add ("C:\Users\YourName\Documents\Report.xlsx")
            .Display ' Use .Send to send automatically without reviewing
        End With
        On Error GoTo 0
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub
      
  6. Customize the Data Sources: Instead of hard-coding the email address as "recipient@example.com", you can link it to a cell. Replace the .To line with: .To = Range("A2").Value. This tells Excel to look at cell A2 for the email address. You can do the same for the Subject and Body lines to make the email dynamic based on your spreadsheet data.
  7. Run the Macro: Close the VBA window and return to your Excel sheet. On the Developer tab, click Macros, select "SendOutlookEmail", and click Run. Outlook will open a new message window with your specified details.
  8. Save the Workbook: Standard .xlsx files cannot store macros. You must go to File > Save As and change the file type to Excel Macro-Enabled Workbook (.xlsm). If you save it as a standard workbook, all your VBA code will be deleted.

Common Mistakes

One of the most frequent errors is forgetting to save the file as an .xlsm. Many users spend time writing complex code only to find it gone the next time they open the file because they saved it as a standard .xlsx. Always verify the file extension before closing the session.

Another common mistake is the "Object Required" error. This usually happens because the user skipped the step of adding the Microsoft Outlook Object Library in the Tools > References menu. Without this reference, Excel does not know what an "Outlook.Application" is, and the code will fail immediately upon execution.

Users also frequently confuse the .Display and .Send commands. Using .Send is efficient for high-volume emails, but if your code has a bug in the recipient list, you could accidentally send hundreds of incorrect emails to clients. It is highly recommended to use .Display during the testing phase so you can manually verify the content before hitting send.

Finally, hard-coding file paths for attachments is a common point of failure. If you use .Attachments.Add ("C:\Documents\File.pdf"), the macro will crash if you move that file or if another user tries to run the macro on their computer where that specific folder path does not exist. Using relative paths or a cell-based path is a safer approach.

Tips

To make your emails look professional, use .HTMLBody instead of .Body. This allows you to use HTML tags to bold text, create lists, or add hyperlinks. For example, .HTMLBody = "Hello <br> Please see the Monthly Report attached." will create a line break and bold the text.

If you need to send emails to a long list of people, wrap your code in a "For Each" or "For Next" loop. By defining a range of cells containing email addresses, the macro can cycle through each row, personalize the greeting based on a name in column B, and send a unique email to every person on the list automatically.

To avoid the Outlook security warning that asks if you want to allow a program to send an email on your behalf, ensure your antivirus software is up to date. Outlook checks the status of your antivirus; if it is recognized and active, the security prompt is often suppressed. If you are in a corporate environment, your IT administrator may have specific group policies that govern this behavior.

Consider adding a confirmation box before the loop starts. Using If MsgBox("Do you want to send these emails?", vbYesNo) = vbNo Then Exit Sub prevents accidental mass-mailing if someone clicks the macro button by mistake.

Troubleshooting

If the macro does not run, first check if macros are disabled. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings and ensure "Disable all macros with notification" is selected. This allows you to enable them via a yellow bar at the top of the screen when the file opens.

If you receive a "User-defined type not defined" error, return to the VBA Editor and check Tools > References. Ensure the Microsoft Outlook Object Library is checked. If you have multiple versions of Office installed, make sure you have selected the most recent version available in the list.

If Outlook is not opening, verify that the Outlook desktop application is actually installed and that you are signed in. This macro cannot interact with the web-based version of Outlook (Outlook.com or OWA) because it requires the local COM API provided by the desktop software.

If the email sends but the attachment is missing, double-check the file path. Ensure the path is absolute (starting with C:\) and that the file extension (e.g., .pdf, .xlsx) is included. If the file is currently open in another program, some security settings may prevent the macro from attaching it.

Frequently Asked Questions

Can I send emails without having Outlook installed?

No, this specific method requires the Outlook desktop application because it uses the Outlook Object Library. To send emails without Outlook, you would need to use CDO (Collaboration Data Objects) or an API from a service like SendGrid, which is significantly more complex to configure.

Will this work with Gmail or Yahoo accounts?

Yes, provided that those accounts are configured as mail profiles within the Microsoft Outlook desktop app. The macro controls the Outlook software, not the email provider, so as long as Outlook can send the mail, the macro will work.

Can I send an email with a range of cells as a table?

Not directly with the .Body property. To send a table, you must either copy the range as an image/object or write a custom VBA function that converts the Excel range into an HTML <table> string to be used in the .HTMLBody property.

How do I stop the macro from sending too many emails at once?

If you are sending hundreds of emails, some mail servers may flag you as spam. You can add a delay to your loop using the Application.Wait command, which tells Excel to pause for a few seconds between each email sent.

Can I attach a specific sheet instead of the whole workbook?

You cannot attach a single sheet directly. You must first use VBA to copy that specific sheet into a new, temporary workbook, save that temporary workbook to a folder, attach that new file, and then delete the temporary file after the email is sent.