VBA

VBA: Send Email With Outlook Mail body Snapshot

In this article you will learn how to send an Outlook Email with mail body snapshot like Excel tables, Charts or images by using VBA. We will use “Mail Envelope” method to sending the email. This method is quite easy and small.

We have to create our data on a worksheet in email format and It will send the entire worksheet or selected range on outlook mail body.

As in the below given image range “A1:H31“will be send to on email. To,CC and Subject information have been given on column L.

Send Email With Outlook Mail body Snapshot
Send Email With Outlook Mail body Snapshot

 

 

How to create a macro to Send Email With Outlook Mail body Snapshot?

  • Copy the below given code
  • Open a new workbook or you can use your existing workbook also.
  • Go to Visual Basic Editor (Press Alt+F11)
  • Insert a new module (Press Alt+I+M)
  • Paste this code.
  • Save workbook as macro enabled.
  • Create the data in mail format.
  • Change the code according to your data range.
Sub Send_Email_With_snapshot()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet1")

Dim lr As Integer
lr = sh.Range("A" & Application.Rows.Count).End(xlUp).Row

sh.Range("A1:H" & lr).Select

With Selection.Parent.MailEnvelope.Item
.to = sh.Range("L6").Value
.cc = sh.Range("L7").Value
.Subject = sh.Range("L8").Value
.attachments.Add "C:\Users\User\Desktop\Projects\Mar-2018.xlsx"
.send
End With

MsgBox "Done"

End Sub

After running this macro, Outlook may show popup as given in below image.

Outlook Popup
Outlook Popup

Click on Allow to send the email.

 

Click here to download this Excel File.

Watch the video tutorial to learn this macro:

PK
My Name is PK. I am founder of PK-AnExcelExpert.com. I am a Microsoft Certified Professional. I have more than 10 years of experience in Data Visualization, Excel Automation and dashboard creation. Excel is my passion and I like to do always something innovative in Excel and share it with other people.
https://www.pk-anexcelexpert.com

Leave a Reply

Your email address will not be published. Required fields are marked *