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.
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.
Click on Allow to send the email.