Hello Wonderfull People,
Please I need your help again.
You will find the picture below
I saved an email Excel attachment in a folder and the name of the attachment in a variable . Then, i use an If activity to verify if the attachment extension is (.xls or .csv). If conditions are true, then i want to change the attachment extension to .xlsx. To do that, i am using a excel proces. please look at the picture below.
My problem is:
i want to recuperate the attachment from the folder i save the initial attachment, then save the attachment with .xlsx, all that with the original name , and in the same folder
Once after verifying with if condition whether it is csv or xls file it goes to then block where use a SAVE ATTACHMENT activity and pass the mailmessage variable as input and folder path where u want to save the file
Repeat the same for all mail messages
Once after saving all the files in that folder now use a Assign activity like this
Where arr_filepath is a variable of type array of string
Now use a for each activity and pass this array variable as input
And change the type argument as string
Inside the loop use a MOVE FILE activity and pass the source filepath as item.ToString and mention the destination filepath like this
So, After reading all the mails & downloaded the attachment to your Folder. Follow my give steps for changing the Extension of your attachments.
Use an Assign Activity and Assign ArrFilePath= Directory.GetFiles(Attchmentfolderpath). Also, Create a Variable name ArrFilePath which is of type Array of String.
Use “For Each” Activity and pass “ArrFilePath” variable. Also, from the For Each Activity properties panel change argument type to string.
Use Assign Activity inside For Each and Pass lv_Filepath=item.ToString in it.
Use a "Move File activity after Assign and your destination file path should be like this Split(lv_Filepath,”.”)(0).ToString + ”.xlsx”
This will change all .xls and .csv files path with “.xlsx” extension.
@Ricchch
Keep in mind that a fileName renaming is not doing a document format conversion (regardless if Excel pretends to open / display a csv file in the Ui)
For conversion a csv file we can do (one of many options)
Read CSV Activity
write range Activity
For calculating the new filename we suggest:
As relying on last dot and first part access will fail as we can see here:
The .04 is lost from filename
Is the Expression Editor path well adressed? Please consider that my intention for the Attach_name variable was store the name of the attachment in this variable just to use it when i wanted to save it again but with the new extension (.xlsx). What is more, i think that “Save Excel File AS” activity will change automatically the extension …
Hello wonderfull People,
Thanks for all your comments. I read it carefully all them and they gave me ideas to rework my workflow. Finally, i found my solution. you’ll see it in picture below