Saving attachment with replaced name

Hello,

Greetings!

I am working on a flow where i need to read the mails with specific subject
i have written workflow for it.
The part where i am facing challenge is i have to save attachment from each read mail and renaming the file to “emailid_timestamp” where timestamp is the time when it is received.

Please help if anyone has worked with similar kind of flow.

Thanks in advance,
Aishwarya

1 Like

I have similar example where you actually move the downloaded file with different name to different folder. You can change it to your desire.

EmailAttachment.xaml (10.6 KB)

Hi
Hope these steps could help you resolve this
— once after saving the file in the folder been mentioned in the save attachment activity
—use a assign activity like this
Out_RecentFile = Directory.GetFiles(“yourfolderpath”,”*.fileextension”).Ordebydescending(Function(d) New FileInfo(d).CreationTime).ToList(0).Tostring
Where Out_RecentFile is a string variable with recent file stored to that folder (as mentioned in the save attachment)
— now use a move file activity where in the source path mention the variable Out_RecentFile and in destination property mention as
“Yourfolderpath”+”\”+”yournewfilename_”+Now.ToString(“dd_MM_yyyy_hh_mm”)

Simple isn’t it
Cheers @Aishwarya_Thakur

2 Likes

Hi @srdjan.suc,
Thanks for your response.
assuming that variable dynamicPart is just used for reference and it will have just incremented number for each mail or pattern we are using to name the attachment(in my case “emailid_timestamp”).

please confirm if am i right?

Yeap.
This was for the purpose of when the attachments have the same name, so the counter was the thing that made a difference

1 Like

Hi @srdjan.suc i am getting error at invoke method activity i have added no new properties and all other properties matches yours.

-Aishwarya

What error are you getting?
Can you screenshot me the Parameters property, maybe you have changed variable Types so you need to change them a bit in the Parameters.

1 Like

Hi aishwarya

Please see the attached xaml. Hope this matches your requirement .

It will rename the attachments in your email to a combination of From address and Timestamp.

EmailAttachment.xaml (12.5 KB)

regards
Vishnuvarthan

3 Likes