Thanks to some great pointers here.
and
I have managed to fudge together a routine that reads the contents of a given folders into a table. I'm only missing a loop that can read the table and attach the files based on it.
My normal code is based on an export of a report and attaches the variable file name. (as below). But in this case I think I need a loop that reads the table and creates the .Attachments.Add based on each row.
With oMail
'
'.To = "To Field"
.Subject = "Please find attached an allocation posting processed by SBL. Ref: " & Me.BatchNumberChoice
.Body = stText
.Attachments.Add fileName
.Attachments.Add fileName2
.Display '<-- comment out this line if you don't first want to view the email before sending.
'.Send '<-- uncomment this line if you want the email to auto send
End With
Attach all files in a folder to an email
Hi all, I've searched in vain so thank you in advance. I want to declare a variable which points to a folder and then have an email created with all files in that given directory attached. They'll will be different names each time, but I want them all attaching automatically. Kind Regards
www.access-programmers.co.uk
Microsoft Access tips: List files recursively
Illustrates how to list files recursively in VBA. Output can be listed to the immediate window or written to a table.
allenbrowne.com
I have managed to fudge together a routine that reads the contents of a given folders into a table. I'm only missing a loop that can read the table and attach the files based on it.
My normal code is based on an export of a report and attaches the variable file name. (as below). But in this case I think I need a loop that reads the table and creates the .Attachments.Add based on each row.
With oMail
'
'.To = "To Field"
.Subject = "Please find attached an allocation posting processed by SBL. Ref: " & Me.BatchNumberChoice
.Body = stText
.Attachments.Add fileName
.Attachments.Add fileName2
.Display '<-- comment out this line if you don't first want to view the email before sending.
'.Send '<-- uncomment this line if you want the email to auto send
End With