Sending Multiple Attachments

DarrylK

New Member
Joined
Mar 6, 2017
Messages
16
Hi,

I am trying to send multiple attachments on an email.

I am using the following code to send a single attachment however I would like to send all the attachments located in Column C on a sheet named "ITEM INQUIRY LIST"

With OutMail
.To = Range("P8").Value
.CC = "Mickey.Mouse@Disney.com"
.Subject = "Encore Glass Samples are on their way to " & Range("R4").Value & " (" & Range("Q6").Value & ")"
.Attachments.Add Range("P30").Value
.Body = EmailBody
.Send
End With

Assistance would be greatly appreciated!
 
Last edited by a moderator:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
If your range does not contain empty cells, then you could first define and assign the range to an object variable...

Code:
Dim rRecipients As Range
Dim LastRow As Long


With Worksheets("ITEM INQUIRY LIST")
    LastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
    Set rRecipients = .Range("C1:C" & LastRow)
End With

And then you could assign the recipients as follows...

Code:
.Attachments.Add Join(application.Transpose(rRecipients), ";")

If your range can contain empty cells, first fill an array with the email addresses...

Code:
Dim aRecipients() As String
Dim rRecipients As Range
Dim rCell As Range
Dim LastRow As Long
Dim Cnt As Long


With Worksheets("ITEM INQUIRY LIST")
    LastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
    Set rRecipients = .Range("C1:C" & LastRow)
End With


ReDim aRecipients(1 To LastRow)


Cnt = 0
For Each rCell In rRecipients
    If Len(rCell) > 0 Then
        Cnt = Cnt + 1
        aRecipients(Cnt) = rCell.Value
    End If
Next rCell


If Cnt = 0 Then
    MsgBox "No data found.", vbExclamation
    Exit Sub
End If


ReDim Preserve aRecipients(1 To Cnt)

Then assign them as follows...

Code:
.Attachments.Add Join(aRecipients, ";")

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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
Back
Top