Send mail with attachment to multiple recipients in outlook using VBA Excel

Send Mail using outlook by vba

Objective

To send a mail with attachment to multiple recipients in outlook using VBA Excel .

Approach

Here we are sending mail to multiple recipients and also attaching a file from local drive.We have also added the text for body in the mail.

 

We need to add below shown outlook library [Microsoft Outlook 16.0 Object Library] in VBA macro file to run this code.

 

Send Mail using outlook by vba

 

Code

Sub SendMail()
Dim MyMailObject  As Object
Dim MyOutlookObject As Outlook.Application
Set MyOutlookObject = New Outlook.Application
Set MyMailObject = MyOutlookObject.Createitem(olMailItem)
With MyMailObject
        .To = "[email protected]"
        .CC = "[email protected]"
        .Subject = "My Mail's subject"
        .Body = "Hi ," & vbCrLf & "This is this first line of my mail's body" & vbCrLf & "This is    the second line in body" & vbCrLf & "Thanks"
        .Attachments.Add "C:\Users\newuser\Desktop\sampleimage.jpg"
        .Send
        End With
    End Sub

 

Post you may like

Find and highlight the empty cells in an excel sheet using VBA

1 comment on “Send mail with attachment to multiple recipients in outlook using VBA Excel

Comments are closed.