Excel VBA Macro: Send Email with All Files (in a Specific Folder) Attached

greggowaffles • March 1, 2022
Video Thumbnail
greggowaffles Logo

greggowaffles

View Channel

About

My mission is to create tutorials that are fun, easy to understand, and connected to real world scenarios.

Video Description

💼 Hire Me for Excel VBA Automation Need help automating your Excel workflows? I specialize in building custom Excel VBA solutions to save you time and eliminate repetitive tasks. 👉 https://www.upwork.com/freelancers/~013bd05e311ebf4a2c #ExcelVBA #ExcelMacroExcel VBA Macro: Attach All Files (in a Specific Folder) to an Email and Send. In this video, we write code in VBA to add all files in a folder to an email using a Do While Loop. Code (YouTube doesn't allow brackets; so LT and GT are used for less than and greater than, respectively): Sub email_all_files_in_folder() Dim OutApp As Object Dim OutMail As Object Dim strbody As String Dim myFldr As String Dim myFile As String Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) myFldr = "C:\Users\greggowaffles\Documents\Youtube Videos\Test\Sample Data Files\" myFile = Dir(myFldr) strbody = "LT BODY style = font-size:11pt; font-family:Arial GT" & _ "Hi Team, LT p GT Please see file(s) attached. LT p GT" & _ "Thanks, LT br GT Greg" On Error Resume Next With OutMail .To = "[email protected]" .CC = "" .BCC = "" .Subject = "Daily File(s) " & Format(Date, "mm/dd/yyyy") .Display .HTMLBody = strbody & .HTMLBody Do While myFile LT GT "" .Attachments.Add myFldr & myFile myFile = Dir Loop End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End Sub #ExcelVBA #ExcelMacro

You May Also Like