How do I attach files with a today's date stamp and send via email?

I have several files in a folder from different days. I need to attach only the ones that were created today and send in an email.

Hi @brettthompson

Welcome to forum

You can filter the files based on creation date wich is created today and then it as attachment via email activities


Nived N

Happy Automation

I can’t seem to get the coding correct.

Hi @brettthompson

Try to filter the files in a directory using the below assign activitiy

file_list= Directory.GetFiles(folderpath).Where(Function (file) FileInfo(file).CreationTime.ToString(“dd/MM/yyyy”).Equals(Now.ToString(“dd/MM/yyyy”)).ToArray()

Then u get a list of file path which were created today

By this u attach those file and send via email


Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed:

1 Like

Gives me an error and states ‘)’ expected

@brettthompson - Please try this…

Code: New System.IO.DirectoryInfo(YourFolderPath).GetFiles().where(Function(file)

Here ArrFileInfo is of variable type system.IO.FileInfo

For Each type argument should be set to system.IO.FileInfo



Desktop Files

Update: Alternate

StrArrFiles = Directory.GetFiles(YourPath).Where(Function(x) New FileInfo(x).CreationTime.Date = DateTime.Today.Date).ToArray

StrArrFiles is of variable type String Array.

If you want to include the subfolders also, then

Directory.GetFiles(YourFolderPath,"*",SearchOption.AllDirectories).Where(Function(x) New FileInfo(x).CreationTime.Date = DateTime.Today.Date).ToArray

1 Like

Thank you for everyone’s input

@brettthompson - Just curios…is it working as expected?? or is it pulling hidden files also??

Working as expected

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.