I think this one is easy for professionals
In my company, we get daily mails with attachments showing the production results of the former evening. There are two shifts in production, so we get one e-mail at 6pm of the first shift and the second e-mail at 2am of the following day from the second shift.
My flow saves the attachements in folders on a sharepoint, which have the naming yyyy-mm-dd.
I solved it whith the
convertTimeZone(utcnow(),'UTC','W. Europe Standard Time','yyyy-MM-dd')
for the first e-mail (this function in folderpath creates automatically a folder with the current date).
While the second mail arrives on the next day, I use
FormatDateTime(AddDays(convertTimeZone(utcnow(),'UTC','W. Europe Standard Time','yyyy-MM-dd'), -1), 'yyyy-MM-dd')
for the attachements to be placed in the same folder as the attachement from the first function.
These ones work fine, but there is a third e-mail, which normally is send in the morning at 9am - no problem when I use the first function, but on monday, there is a special case: I get a mail from fridays production as well as from sundays production. My first function copies both mails in the same folder, which is no problem but it is not correct and I do not like it...
I am looking for a workaround to copy the friday mail attachement in the production day folder of friday, and the sunday mail attachement in the production day folder of sunday.
Luckily, the filenames start with the same characters as my folders do: yyyy-mm-dd_filename.xls. So I think, the easist way is to extract the first ten characters from the filename and copy the attachement in a folder on the sharepoint using these characters for the folderpath.
But unluckily, I do not find a function which cuts parts of the filename off. I tried "substring" but was not able to declare the filename as the textstring of the function:
substring(text: string, startIndex: integer, length: integer)
Can anybody help, either with a function to cut off the substring or with a completely different workaround?
Thanks in advance,
Inside of the Apply to each loop where you are looping through the attachments, you can use the following expression:
I'm sorry, it doesn't work:
When I try to replace the FormatDateTime expression in Folderpath Section with yours
the following error message is shown:
In fact, I do not even know what that means, normally I have an idea when facing an error message...
Can you post a screen shot of your Flow please?