This article features code that you can use to send outlook mail from Excel by using the Microsoft Outlook object model. The below code can be used to send an Outlook mail directly from Excel.
Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject(“Outlook.Application”)
Set OutlookMail = OutlookApp.CreateItem(0)
On Error Resume Next
.To = “email@example.com”
.CC = “”
.BCC = “”
.Subject = “This is a Subject Line”
.Body = “This is a Mail Body.”
.Attachments.Add “C:\Report Folder\Test Report.xlsx”
On Error GoTo 0
Set OutlookMail = Nothing
Set OutlookApp = Nothing
- .display displays the mail with the information provided above. You can use .send instead of .Display to send the mail instantly.
- Mail can be sent to multiple users. Simply use “firstname.lastname@example.org;email@example.com”.
- Multiple Attachments can be sent by using .Attachments.Add “File Path” in the next line.