Save as Outlook attchaments in folder as - Date + Original attachment mail

Capture
Capture1

hi,
I have built a workflow,
as per my sender list and folder path list in excel, save outlook attachment, but I want to add current date before original attachment name while saving.

for example - 20240430_FS Cheat Sheet Revised.docx

You can save all attachments to one folder the way you are currently doing it,

Once done saving all attachments,

Do a for each file in the folder

Assign new file name as:

strNewFileName = System.DateTime.Now.ToString(“yyyyMMdd”) & “_” & System.IO.Path.GetFileName(CurrentItem)

Use the Rename File Activity to change the file name:


2

will this consider all sub folders. because I have multiple files in multiple sub folders
getting these error, please help

Hi @priyanka.solanki

  1. please change type of variable in assign activity to array of string.


2. For each Type of argument should be “string”
3. in your currentitem you can add CurrentItem.Tostring.

Hope it helps!!!

@priyanka.solanki

check the thread

Okay so,

The list files is supposed to be an array of string, see below:

Once you have change the variable type for ListFiles, make sure the for each activity properties are set like this:

TypeArgument: String:

Also this will not work for subfolders, to get files from subfolders as well you would need use this:

System.IO.Directory.GetFiles(“mainFolderPath”, “.”, SearchOption.AllDirectories)

image