Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Manipulate filename from email attachment

I used the SharePoint create file action to save file to SharePoint library from email attachments. It overwrites the file if it already exist. I then try to add with timestamp to the filename but only as prefix because the "Name" dynamic content from email attachment includes file extension. Ideally, the new filename should be [filename]-[timestamp].[file extension]


I am still new to use Flow. Anyone has suggestion or work around for this? Thank you.


Great tutorial. I'm getting this error message: 

The template validation failed: 'The action(s) 'Compose-GetFileName, Compose-GetFileExtension' referenced by 'inputs' in action 'Compose_3' are not defined in the template.'.
Ring any bells?

HI @pagemian 

That means that the name of your actions do not match the names of the actions in the walkthrough. Here's what you can do:

  • You can update the expressions to use the name of your Compose_3 action
  • Or you can rename your Compose actions to match the names I'm using: Compose-GetFileName and Compose-GetFileExtension.

Once you do any of the above, your Flow should be fine. Please do not hesitate to reach out if you have any questions or issues.


Fausto Capellan, Jr
Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

Worked like a charm! Thank you. What I'd really like to do is have the file name be the subject line of the incoming email. Any thoughts? I've removed the Compose-Timestamp function so far.

Nevermind! Changed the input for get filename to email subject. DONE! Thanks again!

Hi @pagemian 


Glad you got it working 😀

Fausto Capellan, Jr
Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!


thank you for this flow works perfectly. 

I was wondering how can I put a condition to exclude certain file types such as .png or jpg as the signature images are also getting captured in this flow?


Hi Fausto, First of all, Thanks.


The method you have posted is working partially for me but there is a glitch I am facing and I am not sure why. I have initialized variables and set everything according to the way you have shown with a difference that I have concatenated a three letter string to the file name instead of date. The file is getting saved in the folder with the right modified name, that is, 3 letter string concatenated with the default name of the Excel file attachment.


The problem is that "[_" is coming at the beginning of the file name and "_]" is coming at the end of the file name after extension. How to get rid of these two parts? The dynamic expression I have used is - 

concat('3 letter string',outputs('Compose-GetAttachmentName'),'.',outputs('Compose-GetExtension'))

Hello @Deepjyoti 

Are those characters coming from the original file name or are they somehow being added with thee new file name? Can you please post a screenshot of the file name?

Thank you.

Fausto Capellan, Jr
Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

Hi @faustocapellanj, Thank you for such prompt response!


These characters are not there in the original file name. They are getting added with the new file name when the file is being saved in the folder by the Power Automate flow. The file I am using is a confidential one - hence, I am not sharing the exact name. Let's say that the file in mail attachment is - FileName-28-08-21.xlsb. It is being saved as - [_String-FileName-28-08-21.xlsb_] whereas the desired result is String-FileName-28-08-21.xlsb.

Helpful resources

MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,206)