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.
Solved! Go to Solution.
Hi @jleung,
This is the approach I took to achieve your desidred outcome. I will make the assumption that you want to create the files in the SharePoint library from attachments every time a new email arrives.This may be a lengthy post since it includes screenshots.
formatDateTime(utcNow(),'yyyMMdd-hhmmss')
first(split(variables('AttachmentName'),'.'))
last(split(variables('AttachmentName'),'.'))
concat(outputs('Compose-GetFileName'),'-',variables('Timestamp'),'.',outputs('Compose-GetFileExtension'))
Please let me know if it works or if you have any questions.
Regards,
Fausto Capellan, Jr
Hi @jleung,
This is the approach I took to achieve your desidred outcome. I will make the assumption that you want to create the files in the SharePoint library from attachments every time a new email arrives.This may be a lengthy post since it includes screenshots.
formatDateTime(utcNow(),'yyyMMdd-hhmmss')
first(split(variables('AttachmentName'),'.'))
last(split(variables('AttachmentName'),'.'))
concat(outputs('Compose-GetFileName'),'-',variables('Timestamp'),'.',outputs('Compose-GetFileExtension'))
Please let me know if it works or if you have any questions.
Regards,
Fausto Capellan, Jr
Thanks so much for your approach. Very detail explanation too and really helpful!
I modified the expression in the (Compose-GetFileName) step so that if the filename includes a dot (.), it will also include it.
The expression is substring(variables('AttachmentName'),0,lastIndexOf(variables('AttachmentName'),'.'))
Hi @jleung,
Glad to hear the approach helped you in completing your Flow.
Regards,
Fausto Capellan, Jr
Excellent solution and works as expected.
I was wondering how I could add the ability to change the actual file name in addtion to adding the date. For example the attachment comes in as book1.xls, in the end I'd like it to post to the SP library as Monday Report-(Todays Date).xls
Thanks,
Kevin
Hi @KevinStef
You can check out step 9 and follow a similar approach using the concat() function. You can set any number of parameters to this function to complete the expression you need for your new file name. Please let me know if you have any questions.
Bravo! Exactly what I needed! Thank you. Would be great if MSFT would simplify this with a simple rename step as the current steps are too many.
Hi Fausto, i tried below format of floe to get attachment and save it on share point document library, but in step 10 in file name field, i am not able to see output option in dynamic content. Please advise.
Hi @RVKONDRA
The file name field in step 10 actually comes from the Compose action in step 9. Were you able to create that step asn shown above? If so, can you please post a screenshot so I can take a look at it?
Thanks,
Fausto Capellan, Jr
Hi Fausto, thanks for coming back. I am unable to put screen shots in this message. Do you know how to put screen shots when you reply?
Hi Fausto, have you received my message with screen shots of my flow?
RVKondra
Hi @RVKONDRA
Yes, I did. Please check your inbox when you have a chance.
I know this is an old thread, but wanted to say thank you very much! I've spent a solid 4 hours trying to figure out how to manipulate names of email attachments with no luck. This worked like a charm.
Any ideas on how this can be modified to get the extension if the file name is "Purchase order - 0012171 Rev .1.pdf" as the solution provided would result in the extension being .1.pdf
I am tring to save only the .pdf files and not the jpg or token files that come with emails but more and more are arriving with extra full stops in the filename that make the current solution report incorrectly as false.
Hi @Kgrange
This post by a community staff shows all the steps needed to achieve your solution. Please try it and let me know.
Brilliant stuff @faustocapellanj - is there any way you could manipulate an attachment name from a Sharepoint list so that it's accessible as an OFT?
I've tried just about every approach I can think of, but each time I try I get a permissions error. I'm trying to inject Powerapps info into an email, send it to a Sharepoint list then return it as an attachment, where it gets emailed to the original author.
Hi @loganl
Can you please post a screenshot of the Flow you've built so I can take a look? Also, please let me know if I'm right: you're manipulating information thru PowerApps and storing it in a SharePoint list. Once that item is created, you need to get it, create a new attachment, and send it to the person that created the item?
Thanks.
That's correct, @faustocapellanj - though I've tried so many different methods now that I'm beginning to believe MS doesn't support manipulating OFTs without getting this error. Here's a stripped-down version of what I'm attempting to do. I understand the mechanics, and can build a workable flow for this, except I can't open the final result!
The only way I know how to directly create the OFT file is simply adding the "OFT" extension to the attachment. I suspect that's where I'm screwing things up.
Your guidance is so appreciated! I'd love to use a format other than OFT, but this will be for a MS sales contest, and the sellers require a brand-approved template.