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.
Welcome to forum
You can filter the files based on creation date wich is created today and then it as attachment via email activities
Regards,
Nived N
Happy Automation
I can’t seem to get the coding correct.
“strFolder”+Now.ToString(“MM.dd.yyyy”)+”.word"
Directory.EnumerateFiles(strFolder)
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
Regards
Nived N
Happy Automation
Gives me an error and states ‘)’ expected
@brettthompson - Please try this…
Code: New System.IO.DirectoryInfo(YourFolderPath).GetFiles().where(Function(file) file.CreationTime.Date=Now.date).ToArray()
Here ArrFileInfo is of variable type system.IO.FileInfo
For Each type argument should be set to system.IO.FileInfo
Output:
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
Thank you for everyone’s input
@brettthompson - Just curios…is it working as expected?? or is it pulling hidden files also??
Working as expected
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.