Monday, June 3, 2013

Send emails through Outlook using Excel

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
    .To = ""
    .CC = ""
    .Subject = "Test Email"
    .Attachments.Add "C:\Test.xlsx"
    .Body = "Test email"
    .Close olPromtForSave
End With

End Sub

1 comment:

  1. 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)":