How to send bulk emails from outlook using excel VBA?
Write a Code to Send Emails from Outlook using Excel VBA
Public Sub DraftOutlookEmails() 'Microsoft Outlook XX.X Object Library is required to run this code 'Variable declaration Dim objOutlook As Outlook.Application Dim objMail As Outlook.MailItem Dim lCounter As Long 'Set objects Set objOutlook = Outlook.Application 'Read details from Excel sheet and draft emails For lCounter = 6 To 8 'You can change the counter as per requirement 'Create a new email item Set objMail = objOutlook.CreateItem(olMailItem) 'To objMail.To = Sheet1.Range("A" & lCounter).Value 'Cc objMail.CC = Sheet1.Range("B" & lCounter).Value 'Subject objMail.Subject = Sheet1.Range("C" & lCounter).Value 'Email Body objMail.Body = Sheet1.Range("D" & lCounter).Value 'Add Attachment objMail.Attachments.Add (Sheet1.Range("E" & lCounter).Value) 'Draft email objMail.Close (olSave) 'Close the object Set objMail = Nothing Next 'Show confirmation message to user MsgBox "Done", vbInformation End Sub
How do we Reference Outlook from Excel?
It is worth to mention that you must have MS Outlook installed in your system to use this code and you also need to add Office reference (Microsoft Outlook XX.X Object Library) in Excel VBA from Menu Bar (Tools>References…). Below are the steps to add Office reference in Excel VBA:
- From the Menu Bar, click on Tools > References…
- Select Microsoft Outlook XX.X Object Library and click on ‘OK’ button
Steps to use this VBA Code
To use this code in your Excel file, follow below steps:
1. Open an Excel file
2. Press Alt+F11
3. Insert a Module (Insert>Module) from menu bar
4. Paste the code in the module
5. Now add a shape in Excel sheet
6. Give a name to the shape like ‘Draft Outlook Emails’
7. Right click on the shape and select ‘Assign Macro…’
8. Select ‘DraftOutlookEmails’ from the list and click on ‘Ok’ button
Download Practice File for Free
To help you practice this code, we have made this code available through practice file. Click on the below link to download the practice file.
Excel VBA Course : Beginners to Advanced
We are currently offering our Excel VBA Course at discounted prices. This courses includes On Demand Videos, Practice Assignments, Q&A Support from our Experts. Also after successfully completion of the certification, will share the success with Certificate of Completion
This course is going to help you to excel your skills in Excel VBA with our real time case studies.
Lets get connected and start learning now. Click here to Enroll.
Secrets of Excel Data Visualization: Beginners to Advanced Course
Here is another best rated Excel Charts and Graph Course from excelsirji. This courses also includes On Demand Videos, Practice Assignments, Q&A Support from our Experts.
This Course will enable you to become Excel Data Visualization Expert as it consists many charts preparation method which you will not find over the internet.
So Enroll now to become expert in Excel Data Visualization. Click here to Enroll.