Send Outlook Mail from Excel VBA

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.

Sub SendOutlookEmail()

Dim OutlookApp As Object
Dim OutlookMail As Object

Set OutlookApp = CreateObject(“Outlook.Application”)
Set OutlookMail = OutlookApp.CreateItem(0)

On Error Resume Next

With OutlookMail

.To = “abc@xyz.com”
.CC = “”
.BCC = “”
.Subject = “This is a Subject Line”
.Body = “This is a Mail Body.”
.Attachments.Add “C:\Report Folder\Test Report.xlsx”
.display

End With

On Error GoTo 0

Set OutlookMail = Nothing
Set OutlookApp = Nothing

End Sub

Note:

  • .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 “abc@xyz.com;def@xyz.com”.
  • Multiple Attachments can be sent by using .Attachments.Add “File Path” in the next line.