Microsoft Flow save email attachment with Hebrew Letter to OneDrive or SharePoint


Theoretically you could just use the OOTB template to save a GMAIL to SHAREPOINT


But... As always with MS, nothing is really that simple. All you need to break this flow is a special Character...


So here starts a journey to clean special characters, and i followed this blog post.

My spec was to create some Folder under the default Documents Library of a modern Team Site, and each attachment sent to a specific Gmail account, to be saves in a sub-folder with the sender's name, and another sub-sub-folder with the subject name

https://tenant.sharepoint.com/sites/my-team-site/Documents/emails Attachments/Sender Name/email subject/file name.ext

Playing with Flows, I 1st learned that in order for the flow to be triggered WITH attachments you must change "Has Attachments" and "Include Attachments" to "Yes", both under advanced options under "When a new email arrives" event


Now we can start talking about the actual flow logic

Part 1 - Define Array of Special Characters

The process of cleaning a string from special characters is using "Apply For Each" step and replacing one special character one at a time from the string. Therefor you need an array of special characters to use each time you want to clean a string, so you need to "Initialize Variable" with type or array

Unlike the post I used to learn this logic my array is shorter

createArray('@','´','^','=','~','#','%','*',':','<','>','/','|','"')


Part 2 - Define Variables to be cleaned 

For each parameter you want to clean form special characters you need to define 2 variables, one for the results and another Temp one (*I did not test without the Temp).

At each result set the value to the initial value, and the temp can be left empty, so for the sender make "CleanSenderName" and "TempSender", and again for subject and filename (total of 6 variables to initialize other than the array).




Part 3 - Clean Sender and Subject

As stated, you need to use "Apply to each" step, using the "InvatidCharacters" array as Input, and replacing the current characters (image includes only sender name, you need another 2 similar steps for subject)

*replace 'CleanSenderName' with each variable's name
replace(variables('CleanSenderName'), item(), '')





Part 4 - Clean Attachments Name

Its the same process as above only you must do it under "Apply to each" nested within "Apply to each" of Attachments



Part 5 - Create File

That's one easy now, since "Create File" step creates a folder for you if it does not exists.
*Tip - if you select a folder from the folder icon you cant enter any other characters to the "Folder Path" input, so just delete everything there and type it






Comments

Popular posts from this blog

OverTheWire[.com] Natas Walkthrough - JUST HINT, NO SPOILERS

Asp.Net Ending Response options, Response.End() vs CompleteRequest()

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem