Forum Discussion
Concat "Todays Date" for File Name - Save Attachment - Help
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).
Does this give you what you're after?
Sandy
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. :)
- ARadtkeMar 19, 2021Copper ContributorHello 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:- Damien_RosarioMar 23, 2021Silver Contributor
Hi ARadtke
Don't forget to add .pdf to the back of the filename if you haven't already done so.
Cheers
Damien
- Justin_GanglMar 26, 2021Copper Contributor
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:
attachmentname.pdf
attachmentname.xlsx
Desired attachment filenames in SPOL:
attachmentname_03-26-2021-2-10-PM.pdf
attachmentname_03-26-2021-2-10-PM.xlsx
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.