Here is the VBA code to send emails from Outlook:
Sub SendEmails()
Dim OlApp As Object
Dim OlMail As Object
Set OlApp = CreateObject("Outlook.Application")
Set OlMail = OlApp.CreateItem(olMailItem)
With OlMail
.Display
.To = "aaa@gmail.com"
.CC = "bbb@gmail.com"
.Subject = "Test Email"
.Attachments.Add "C:\Test.xlsx"
.Body = "Test email"
.Save
.Close olPromtForSave
.Send
End With
End Sub
Sub SendEmails()
Dim OlApp As Object
Dim OlMail As Object
Set OlApp = CreateObject("Outlook.Application")
Set OlMail = OlApp.CreateItem(olMailItem)
With OlMail
.Display
.To = "aaa@gmail.com"
.CC = "bbb@gmail.com"
.Subject = "Test Email"
.Attachments.Add "C:\Test.xlsx"
.Body = "Test email"
.Save
.Close olPromtForSave
.Send
End With
End Sub
You might have come across with cases where you wanted to paste range of data from Excel into the body of the email. Please refer to the useful link, use the code "Function RangetoHTML(rng As Range)":
ReplyDeletehttp://www.rondebruin.nl/win/s1/outlook/bmail1.htm