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

shanboy

New Member
Joined
May 17, 2019
Messages
1
Hi,
i have a dashboard and wanted to send via outlook email. i'm new to VBA and i'm using excel 2010. below is the code when i run the code their an error (Run-time error '-2147467259 (80004005)':
Method 'MailEnvelope' of object'_Worksheet'failed). here is the code. kindly assist and thank you


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("p3").Value
.cc = sh.Range("p4").Value
.Subject = sh.Range("p5").Value
.send
End With

MsgBox "Done"

End Sub
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Watch MrExcel Video

Forum statistics

Threads
1,099,134
Messages
5,466,863
Members
406,506
Latest member
Patb3

This Week's Hot Topics

Top