When users send emails to their customers or bosses it’s quite hard to keep track. In that case, Excel comes in handy. Therefore, “send automatic email from Excel to Outlook” has been proven to be a time-saving approach. Excel VBA Macros and the HYPERLINK function can send automatic emails or create a draft using Excel entries.
Let’s say we have Employee Restructured Salary data in Excel and we want to send automatic email using Outlook.
In this article, we demonstrate multiple variants of VBA Macros and the HYPERLINK function to send automatic email from Excel to Outlook.
Download Excel Workbook
Before proceeding to demonstrate any methods, it’s necessary to know the ways to open and insert a Module in the Microsoft Visual Basic in Excel.
🔄 Opening Microsoft Visual Basic: There are mainly 3 ways to open Microsoft Visual Basic window.
1. Using Keyboard Shortcuts: Press ALT+F11 altogether to open Microsoft Visual Basic window.
2. Using Developer Tab: In an Excel worksheet, Go to Developer Tab > Select Visual Basic. The Microsoft Visual Basic window appears.
3. Using Worksheet Tab: Go to any worksheet, Right-Click on it > Choose View Code (from the Context Menu).
🔄 Inserting a Module in Microsoft Visual Basic: There are 2 ways to insert a Module in Microsoft Visual Basic window,
1. Using Sheet’s Options: After opening the Microsoft Visual Basic window, select a Worksheet > Right-Click on it > Select Insert (from the Context Menu) > then choose Module.
2. Using Toolbar: You can also do it by selecting Insert (from the Toolbar) > then choosing Module.
4 Easy Ways to Send Automatic Email from Excel to Outlook
Method 1: Using VBA Macro to Automatically Send Email Using Outlook to Selected Recipients
We want to create a Macro execution Button by which we can simply send mail to selected recipients with just a click.
Step 1: Go to the Insert tab > Shapes > Select any of the offered shapes (i.e., Rectangular: Rounded Corners).
Step 2: Drag the Plus Icon wherever you want to insert the Shape as shown in the image below.
Step 3: Choose a preferred Shape Fill and Outline Color then right-click on it. Click on Edit Text to insert text.
Step 4: Use the instruction to open Microsoft Visual Basic and insert Module. Paste the following Macro in the Module.
Sub ExcelToOutlookSR() Dim mApp As Object Dim mMail As Object Dim SendToMail As String Dim MailSubject As String Dim mMailBody As String For Each r In Selection SendToMail = Range("C" & r.Row) MailSubject = Range("F" & r.Row) mMailBody = Range("G" & r.Row) Set mApp = CreateObject("Outlook.Application") Set mMail = mApp.CreateItem(0) With mMail .To = SendToMail .Subject = MailSubject .Body = mMailBody .Display ' You can use .Send End With Next r End Sub
➤ in the code,
1 – start the macro procedure by declaring the variables as Object and String.
2 – run a VBA FOR loop for each row in the selection to assign Email’s Send To, Subject, and Body using row entries.
3 – assign variables.
4 – perform the VBA With statement to populate Outlook items such as Send To, Mail Subject, etc. Here the macro only executes the Display command to bring out Outlook with an email draft. However, if Send command is used in place or after Display, Outlook will send the created email to the selected recipients.
5 – finish the VBA FOR loop.
Step 5: Return to the Worksheet. Right-click on the Shape then select Assign Macro from the Context Menu options.
Step 6: Select the Macro (i.e., ExcelToOutlookSR) under the Macro name and choose the Macro in option as This Workbook. Click on OK.
Step 7: Now, in the worksheet, select one or multiple employees then click on the Shape Button.
Step 8: Excel prompts Outlook to lunch and creates or sends emails to the selected employees. As you select two of the employees, Outlook generates two different email drafts ready to be sent.
As the macro only provides the Display command, Outlook just displays the email draft without sending it. Use the Send command to automatically send emails from Excel to Outlook using cell entries.
Method 2: Sending Email Automatically from Excel to Outlook Depending on Specific Cell Value
What if we want to send automatic email after achieving targets from Excel to Outlook? A Macro code can do this job with ease.
Suppose, we have Quarterly Sales Data as depicted below, after achieving a target (i.e., Sales> 2000) will automatically prompt Outlook to send an email from Excel to an assigned email id.
Step 1: Type the following macro code in any Module.
Option Explicit Dim Rng As Range Sub Worksheet_Change(ByVal mRng As Range) On Error Resume Next If mRng.Cells.Count > 1 Then Exit Sub Set Rng = Intersect(Range("F17"), mRng) If Rng Is Nothing Then Exit Sub If IsNumeric(mRng.Value) And Target.Value > 2000 Then Call ExcelToOutlook End If End Sub Sub ExcelToOutlook() Dim mApp As Object Dim mMail As Object Dim mMailBody As String Set mApp = CreateObject("Outlook.Application") Set mMail = mApp.CreateItem(0) mMailBody = "Greetings Sir" & vbNewLine & vbNewLine & _ "Our outlet has quarterly Sales more than the target." & vbNewLine & _ "It's a confirmation mail." & vbNewLine & vbNewLine & _ "Regards" & vbNewLine & _ "Outlet Team" On Error Resume Next With mMail .To = "[email protected]" .CC = "" .BCC = "" .Subject = "Notification on Achieving Sales Target" .Body = mMailBody .Display 'or you can use .Send End With On Error GoTo 0 Set mMail = Nothing Set mApp = Nothing End Sub
➤ From the above image, in the sections,
1 – assign a cell (i.e., F17) within a range to execute the VBA IF statement. If the statement results in True, the macro calls another macro for execution.
2 – declare variable types and assign them to populate Outlook’s entries.
3 – perform VBA With statement to assign variables to email entries. Use the Send command instead of Display in case you directly want to send emails without reviewing them. The recipient email is inserted within the macro. Use alternative methods in case you want an automatic insertion of the recipient’s email id.
4 – clear certain variables from assignation.
Step 2: Use the F5 key to run the macro. In a moment, Excel fetches Outlook with a draft email created automatically as shown in the followings. You can click on Send or auto-send using Send command in the macro.
- How to See Who Is in a Shared Excel File (With Quick Steps)
- Enable Share Workbook in Excel
- How to Share Excel File for Multiple Users
- How to Apply Macro to Send Email from Excel with Attachment
Method 3: Using VBA Macro to Send Email with Active Worksheet from Excel by Outlook
Alternatively, there may be instances where we need to send an entire Active Sheet to an assigned email address. In that case, we can use a VBA Custom Function to be called within a macro.
Step 1: Insert the below macro in the Module.
Function ExcelOutlook(mTo, mSub As String, Optional mCC As String, Optional mBd As String) As Boolean On Error Resume Next Dim mApp As Object Dim rItem As Object Set mApp = CreateObject("Outlook.Application") Set rItem = mApp.CreateItem(0) With rItem .To = mTo .CC = "" .Subject = mSub .Body = mBd .Attachments.Add ActiveWorkbook.FullName .Display 'or you can use .Send End With Set rItem = Nothing Set mApp = Nothing End Function Sub OutlookMail() Dim mTo As String Dim mSub As String Dim mBd As String mTo = "[email protected]" mSub = "Quarterly Sales Data" mBd = "Greetings Sir" & vbNewLine & vbNewLine & _ "Kindly find Outlet's Quarterly Sales data attached with this mail." & vbNewLine & _ "It's a notification mail." & vbNewLine & vbNewLine & _ "Regards" & vbNewLine & _ "Outlet Team" If ExcelOutlook(mTo, mSub, , mBd) = True Then MsgBox "Successfully created the Mail draft or Sent" End If End Sub
➤ From the above image, the code’s sections,
1 – declare and set the variables.
2 – assign the commands using the VBA With statement. Use the Display or Send command for reviewing or direct sending emails respectively.
3 – clear the previously set variables.
4 – assign the VBA With commands with texts.
5 – execute the VBA Custom Function.
Step 2: To execute the macro press F5, and instantly Excel brings out the Outlook with a draft email to review similar to the below image. Afterward, you are good to send it.
Method 4: Sending Automatic Email from Excel to Outlook Using HYPERLINK Function
The HYPERLINK function generates a clickable link in Excel cells to bring Outlook as a medium to send automatic emails from Excel.
Step 1: Type the following formula in cell H5.
The HYPERLINK function takes “MailTo:”&C5&”?Subject=”&F5&”&cc=”&$D$2&”&body=”&G5 as link_location, and “Click Here” as friendly_name.
Step 2: Hit ENTER to paste the link. Then click on the link.
Step 3: Excel takes you to Outlook. And you see all the Outlook entries are filled with assigned data from Excel. Click on Send.
Step 4: Drag the Fill Handle to apply the formula to other cells.
VBA Macro Variants and HYPERLINK function can be helpful while sending automatic emails from Excel to Outlook. Hope you find your preferred method within the above-described ones. Comment, if you have further inquiries or have anything to add.
- Send Reminder Email Automatically from an Excel Worksheet Using VBA
- How to Send an Editable Excel Spreadsheet by Email (3 Quick Methods)
- Macro to Send Email from Excel with Body (3 Useful Cases)
- How to Automatically Send Email from Excel Based on Date
- How to Send Email from Excel with Body Using a Macro (with Easy Steps)