Concat "Todays Date" for File Name - Save Attachment - Help

Iron Contributor



Can anyone give me some quick tips or is it even possible.



Report to a mailbox comes everyday, named the same.

Want to remove the report from the email, save it to a SharePoint Site with a time date.

Simple attempts to concat a text name of the file and a date are not working out real well.


Anyone help a Flow Noob? Please?

10 Replies

Hi @Rob Bowman,


A quick way to do this would be to go to the appropriate SharePoint document library, and Create a Flow, using the Flow template called "Save my email attachments to a SharePoint document library". This template should automatically create an Apply to Each Attachment loop, with a Create File action inside it. In the Create File, the default filename is the "Name" which comes from that attachment. You can click in that area to append another field to the filename, and select Received Time from the Dynamic Content dialog (you may need to click See More next to the On New Email header in the Dynamic Content dialog, to see more fields available). That should do it - does this help?


Note that this will append the UTC time, which is how O365 stores things. If you want the time stamp to be your local time, you'd need to add some steps (see my screenshot below):

  • Within the Apply to Each Attachment loop, click the + icon just above the Create File action, and find the action called Convert Time Zone (it's one of the relatively new Date Time connector actions). You'll be prompted for a Base Time (select the Received Time as above), Source time zone (which is UTC), and Destination time zone (yours) and format (whatever you want from the list).
  • I found that the result of the Convert Time Zone action doesn't seem to be available to add to the file name in the Create File step, but you can add a Compose action just after Convert Time Zone, and for the Input select Converted Time from the Dynamic Content dialog.
  • Then in the Create File filename, instead of Received Time, select Output (from the Compose action) to append to Name (I added a space also, for legibility).

DateTime stamp in attachment filename.png 


Does this give you what you're after?



@Sandy Ussia Really wish I would have checked back on this! I spent my Saturday afternoon coming up with something similar. Did not know about the "Convert Time Zone" function! That looks like a handy one! I ended up using the "Name" and "Date Received" in the create file function.


Thank you for responding though. As usual I learned a few things. :)

Hello Sandy, hello Rob,

I have the same requirement. I tried to add the attachments filename+Received Time. But now it seems that the flow shreds the file and the file is no longer a PDF file that can be opened it is an unknown filetype with a filename that did not reflect the expected filename as configured in the create file section in my flow:

Hi @ARadtke 


Don't forget to add .pdf to the back of the filename if you haven't already done so.




Hi @Damien Rosario ,


I'm having the same issue with my attachment filename.  I have 2 files with the same name coming into a mailbox as attachments, one is a .pdf and the other is a .xlsx.  I want to remove the files from the email, and save them to a SharePoint library with today's date/time added to the filename.


Current attachment filenames:




Desired attachment filenames in SPOL:




In my Create File action, in the File Name field, I've tried using 'Attachments Name'_'Received Time' dynamic content dialogue.   



That appends the date after the file extension, attachmentname.pdf_03-26-2021-2-10-PM, giving an unknown filetype.


If I add .pdf in the File Name,  


then I get a usable filename, attachmentname.pdf_03-26-2021-2-10-PM.pdf, but it obviously changes my xlsx file to a pdf extension as well.


Any thoughts on how to accomplish this?  Appreciate any help you can provide. 


@Justin_Gangl you can do this if you split the attachment name on the .dot. You need several Compose controls as shown below:











Los Gallardos
Microsoft Power Automate Community Super User.
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

Hi @Justin_Gangl 


Rob's solution covers a solution pretty well in the order you want to see it in.


Alternatively, you could put the received date at the front of the name followed by the file name. This way the extension will always work and will require no additional actions.


Cheers and best wishes


Perfect! This solves my issue. Thanks so much!



Hello , Have used the formatdatetime('utcnow()', 'g) and added a connection to convert time zone to Eastern Standard time. While pulling in this to my file name, the format of output is coming as <filename>_MM_DD_HH HH_MM AM. I would like to get this in following format <filename>_MM/DD/HH HH:MM AM


Any Leads. Thank You !!!