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
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