Forum Discussion
Concat "Todays Date" for File Name - Save Attachment - Help
All,
Can anyone give me some quick tips or is it even possible.
Scenario:
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?
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
- Rob BowmanIron Contributor
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. :)
- ARadtkeCopper 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: