VBA to add all files in a folder to an email

Add all files in folder to an email

VBA that will add all files in folder to an email.  Loops the folder and attaches each file to the email.


Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
 .To = "Dylan.Gregory@vba-market.com"
 .CC = "CC@email.com"
 .Subject = "Subject Line"
 .HTMLBody = "Add all attachements in folder … "
 strPath = "Z:\My Documents\tempFolder\"
 StrFile = Dir(strPath & "*.*")
 Do While Len(StrFile) > 0
 .Attachments.Add strPath & StrFile
 StrFile = Dir

End With