SteveL13
asked on
Trying to add multiple files to an email message
I am using the following code in an attempt to attach multiple files to an email. In some cases there may be just one file to attach but in other cases more than one. The code as it exists right now only sends the first file even if there are two files to be send. It needs to send both files in the email if there are more than one.
strAttachment = Me.txtCastingPrintsDataPath 'strAttachment is the path to the attachments
For j = 1 To 5
filename = Dir(strAttachment)
If Me("chkbxPatternSource" & j) = True Then
Set objMail = olApp.CreateItem(olMailItem)
strEmail = Me("txtPatternSourceEmail" & j) & ";"
With objMail
.To = strEmail
.Subject = strSubject
.HTMLBody = strHTMLBody
.Attachments.Add strAttachment & filename
.Send
End With
End If
Next
Set objMail = Nothing
Set olApp = Nothing
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER