You can send emails from Excel using Outlook by utilizing a VBA (Visual Basic for Applications) macro. This process allows you to automate repetitive emailing tasks, such as sending personalized invoices, reports, or notifications to a list of recipients, directly from your spreadsheet data. To achieve this, you will need both the desktop version of Microsoft Excel and the desktop version of Microsoft Outlook installed and configured on the same computer.
What You'll Need
- Microsoft Excel (Desktop version).
- Microsoft Outlook (Desktop version, signed into an active email account).
- A dataset in Excel containing at least one column for email addresses and one for the message content or recipient names.
- The "Developer" tab enabled in the Excel Ribbon.
Step-by-Step
- Enable the Developer Tab: If you do not see the Developer tab at the top of your Excel window, right-click any existing tab (like Home or Insert) and select Customize the Ribbon. In the right-hand list, check the box next to Developer and click OK.
- Prepare Your Data: Organize your spreadsheet so that your data is in a clean table. For example, put "Email Address" in Column A, "Recipient Name" in Column B, and "Subject" in Column C. Ensure there are no empty rows within your data set.
- Open the VBA Editor: Click the Developer tab and select Visual Basic (or press Alt + F11 on your keyboard).
- Insert a New Module: In the VBA editor menu, go to Insert > Module. This opens a blank white window where you will enter the automation code.
- Enter the Automation Code: Copy and paste the following code into the module window. Note that menu labels and object names may vary slightly depending on your version of Office.
Sub SendEmails() Dim OutApp As Object Dim OutMail As Object Dim cell As Range Set OutApp = CreateObject("Outlook.Application") For Each cell In Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row) Set OutMail = OutApp.CreateItem(0) With OutMail .To = cell.Value .Subject = cell.Offset(0, 2).Value .Body = "Hello " & cell.Offset(0, 1).Value & "," & vbCrLf & vbCrLf & "This is an automated message." .Display 'Use .Send to send immediately without reviewing End With Set OutMail = Nothing Next cell Set OutApp = Nothing End Sub - Customize the Code: Adjust the
Range("A2:A"...)part of the code to match the column where your email addresses are located. TheOffset(0, 1)andOffset(0, 2)commands tell Excel to look one and two columns to the right of the email address for the name and subject, respectively. - Run the Macro: Close the VBA window to return to your spreadsheet. On the Developer tab, click Macros, select "SendEmails" from the list, and click Run.
- Save the Workbook: Because this file contains a macro, you must save it as an Excel Macro-Enabled Workbook (.xlsm). If you save it as a standard .xlsx file, the code will be deleted.
Common Mistakes
- Saving as .xlsx: The most frequent error is saving the file in the default format, which strips all VBA code. Always use .xlsm.
- Incorrect Range References: If your data starts on row 5 instead of row 2, the code will fail or send emails to the wrong cells. Double-check your
RangeandOffsetvalues. - Outlook Not Open: While the code can often launch Outlook, the process is much more stable if Outlook is already open and running in the background.
- Using .Send Immediately: Using
.Sendinstead of.Displaycan lead to hundreds of emails being sent instantly if there is an error in your data. Always use.Displayfor your first few tests.
Tips
- HTML Formatting: If you want bold text, colors, or links in your email, change
.Bodyto.HTMLBodyand use standard HTML tags (e.g.,<br>for line breaks). - Adding Attachments: You can add a file to the email by adding the line
.Attachments.Add ("C:\path\to\your\file.pdf")inside theWith OutMailblock. - Dynamic Body Text: Instead of a hardcoded string, you can reference another cell for the body of the email using
.Body = cell.Offset(0, 3).Value.
Troubleshooting
If the macro does not run or produces an error, try these steps in order:
- Check Macro Settings: Go to File > Options > Trust Center > Trust Center Settings > Macro Settings. Ensure "Disable VBA macros with notification" is selected so you can enable them when the file opens.
- Verify Outlook Account: Ensure you have a default email account set up in Outlook. If no default account exists, the
CreateObjectfunction will fail. - Check for Security Prompts: Some versions of Outlook will trigger a security warning asking if you want to allow a program to send emails on your behalf. You must click "Allow" for the macro to proceed.
- Restart Applications: Close both Excel and Outlook completely via the Task Manager and restart them to clear any hung processes.
Frequently Asked Questions
Can I send emails from Excel using the web version of Outlook?
No, VBA macros require the desktop application of Outlook to interact with the system's API. For web-based automation, you would need to use Power Automate.
Will this work if I have multiple email accounts in Outlook?
By default, the macro uses the default account set in Outlook. To use a specific account, you would need to modify the code to specify the SendUsingAccount property.
Is there a limit to how many emails I can send this way?
Excel has no limit, but your email provider (e.g., Microsoft 365, Gmail, or an ISP) usually has daily sending limits to prevent spam. Check your provider's limits to avoid having your account suspended.
Can I send a different attachment to each person?
Yes. You can put the file path for each attachment in a specific column in your spreadsheet and reference that cell using the .Attachments.Add command within the loop.
Do I need to be a programmer to use this?
No. While this uses VBA, you only need to copy the provided code and adjust the column letters to match your specific data layout.