Excel Macro To Send Email Automatically (3 Suitable Examples)
Có thể bạn quan tâm
Complete the following steps before applying a macro to send email automatically.
STEPS:
- From your dataset, go to the Developer tab. Select the option Visual Basic.
- Go to the Tool tab and select the option References.
- A new dialogue box named ‘References – VBAProject’ will open.
- Check the option ‘Microsoft Office 16.0 Object Library’ and click OK.
Method 1 – Applying Excel VBA Macro to Send Email Automatically Based on Cell Value
STEPS:
- Right–click on the sheet ‘Based on Cell’.
- Select the option ‘View Code’.
- A blank VBA code window will open. Another way to open that code window is to press Alt + F11.
- Enter the following code in that code window:
- Click the Run button or press F5 to run the code.
- A new dialogue box named Macros will appear.
- In the Macro Name field, select the macro ‘send_mail_outlook’.
- Click on the Run button.
- When the cell value in cell D6 > 400 an email in Outlook will generate automatically with specific recipients. We have to just click on the Send button to send the email.
Read More: Excel Macro: Send Email to an Address in Cell
Method 2 – Sending Email Automatically Based on Due Date with VBA Macro
STEPS:
- Right-click on the sheet Date.
- Select the option ‘View Code’.
- A blank VBA code window opens. We can also press Alt + F11 to get that code window.
- Enter the following code in the code window:
- Use the Run button or the F5 key to run the code.
- A new dialogue box will pop up.
- In the input field of that dialogue box, select the due date column range D$5:$D$9.
- Click on OK.
- A dialogue box will pop up.
- In the input field, select the column range B$5:$B$9 that contains the email addresses and click on OK.
- A window will pop up. Select the message range $C$5:$C$9 in the input field of the pop window.
- The results are shown in the following image. We get three emails that are automatically created in three different windows of Outlook. This will not create mail for the first two email addresses because the due date of those two projects is over.
Read More: How to Apply Macro to Send Email from Excel with Attachment
Method 3 – Using Excel Macro to Send Email Automatically with Attachments
- Select the file ‘Attachment.xlsx’’.
- Click on the option ‘Copy Path’.
- The path of the file that we get:
Insert this path in our macro code to send this file by email.
STEPS:
- Go to the Developer tab and select the option Visual Basic.
- A new window named ‘Project – VBAProject will open.
- Right-click on the sheet name.
- Select Insert > Module.
- A blank VBA will open.
- Enter the following code in that module:
- Hit F5 or click the Run button to run the code.
- The code will send the attachment to the provided emails in the code. The code sends emails by Outlook.
- Click the Allow button to let Outlook send the attachment to the given emails.
Read More: Send Email from Excel VBA without Outlook
Download the Practice Workbook
You can download the practice workbook from here.
Send Email Automatically.xlsmRelated Articles
- Send Reminder Email Automatically from an Excel Worksheet Using VBA
- VBA to Generate Multiple Lines in Email Body in Excel
- Macro to Send Email from Excel
- How to Send Email from Excel with Body Using a Macro
- Print to PDF and Email Using VBA in Excel
- How to Use Excel VBA to Paste Range into Email Body
Từ khóa » Visual Basic Code To Send Email From Excel
-
VBA Send Email From Excel - WallStreetMojo
-
How To Send Emails From An Excel Spreadsheet Using VBA Scripts
-
How To Send Email In Excel Using VBA? - Simplilearn
-
VBA To Automate Sending Email From Excel Table With Attachment ...
-
Send Emails With Attachments From Excel Using VBA And Outlook
-
VBA Send Emails From Excel Through Outlook
-
How To Send Emails From Using Excel VBA? - EduCBA
-
Send Email From Excel Using VBA And VBScript - Tutorial
-
Sending Email To A List Of Recipients Using Excel And Outlook
-
Sending Email With VBA: Learn In 11 Simple And Easy Steps
-
VBA Send Email From Excel
-
Mail From Excel With Outlook (VBA) - Ron De Bruin Excel Automation
-
Send Emails Using VBA From Excel Sheet With Multiple Recipients