To send a mail with attachment to multiple recipients in outlook using VBA Excel .
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.
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