How to attached multiple attachments on email

jmazorra

Well-known Member
Joined
Mar 19, 2011
Messages
707
Hello folks.

I have a code to attached a .pdf and email to recipients on an excel sheet. The current code only attaches one file, however I would like to attach a second file to the email called "CEO Letter.pdf", found in the same directory, along with the particular file. Here is my spreadsheet:

Capture.PNG



Here is my code:

VBA Code:
Option Explicit
Sub SendEmailAttachment()


Dim Email As String
Dim subj As String
Dim message As String
Dim filename As String
Dim outlookapp As Object
Dim outlookmailitem As Object
Dim myAttachments As Object
Dim path As String
Dim lastrow As Integer
Dim attachment As String
Dim x As Integer


 x = 2

Do While Sheet1.Cells(x, 1) <> ""
   
    Set outlookapp = CreateObject("Outlook.Application")
    Set outlookmailitem = outlookapp.createitem(0)
    Set myAttachments = outlookmailitem.Attachments
    path = "C:\Users\JAMazorra\OneDrive - Lane Construction\Desktop\Statements"
    edress = Sheet1.Cells(x, 1)
      
    subj = Sheet1.Cells(x, 2)
    filename = Sheet1.Cells(x, 3)
    attachment = path + filename


    
        outlookmailitem.To = Email
        outlookmailitem.cc = ""
        outlookmailitem.bcc = ""
        outlookmailitem.Subject = subj
        outlookmailitem.body = "Please find your statement attached" & vbCrLf & "Best Regards"
           
            
        myAttachments.Add (attachment)
        outlookmailitem.display
        outlookmailitem.send
            
        lastrow = lastrow + 1
        edress = ""
    x = x + 1

Loop


Set outlookapp = Nothing
Set outlookmailitem = Nothing

End Sub
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,144,154
Messages
5,722,815
Members
422,460
Latest member
VBA_Noob01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top