Attach all files in a folder to an email (1 Viewer)

FrostByte

Registered User.
Local time
Today, 12:32
Joined
Jan 15, 2015
Messages
56
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
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:32
Joined
Sep 21, 2011
Messages
14,305
Plenty of examples here and elsewhere on how to attach a file to an email.
Combine that in a loop that reads all the files in a folder.
Plenty of examples for that also.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 04:32
Joined
Oct 29, 2018
Messages
21,473
Most, if not all, email servers have a limit on file size attachments. You might also consider zipping them up first to reduce the amount of time for the recipient to download the email attachments.
 

FrostByte

Registered User.
Local time
Today, 12:32
Joined
Jan 15, 2015
Messages
56
Plenty of examples here and elsewhere on how to attach a file to an email.
Combine that in a loop that reads all the files in a folder.
Plenty of examples for that also.
I have the code to attach a file after its exported to a directory in a single routine.

In his instance however these files are not from an export. There placed in the directory days before from other processes, I guess I'm unsure of how to read the contents and then use that information to loop and attach them.
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:32
Joined
Sep 21, 2011
Messages
14,305
Here is one of the links for processing all files.
I was thinking more of the Dir() function.

 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 06:32
Joined
Feb 28, 2001
Messages
27,186
You can do this using the FileSystemObject in your VBA.


The above link points you to the top of a "tree" of articles relating to the FSO. Each of the articles shows you a snippet of code to do something. What you want to do is create a folder object based on a particular drive letter and path, then there is a collection of files IN that folder that you can visit using a "For Each file" type of loop. Each member of the collection IS a file object and you can get info about it like name, creation date, size, etc. Look through the articles under the link for the various details.

This forum will also have many articles on use of the File System Object, so the search function (upper right of the screen on the menu bar) can be used to find articles. HOWEVER - also look at the "similar threads" list, which will often contain relevant articles based on the Xenforo software's topic-search algorithms.
 

Users who are viewing this thread

Top Bottom