Why?
Again we should ask: “Why do you want to email something from SharePoint” multiple times, but let me show you how in case we would need to send multiple attachments.
What?
In the previous post (https://knowhere365.space/microsoft-flow-attach-a-file-from-sharepoint-to-email/) we already managed so send one attachment in an email and now we will step the game up with a dynamic number of attachments.
How?
If we configured all the steps in the post linked above, we may have had the feeling that some actions could be eliminated. However because of stability and the new requirement in this post, all we now have to do is reorder some actions and add a few:
1) Getting the Identifier of multiple files in SharePoint could be achieved using the Get files action:
2) A Get files action will always have a chance of getting multiple results so Flow puts it in an array. Using the results of such an action outputting an array in a next action, will place this next action in an Apply to each control:
3) Now we will reorder all the template file actions explained in the previous post. Just place these actions in the new Apply to each control and use the Identifier of the Get files action as the File Identifier of every action:
The code of the value within the Apply to each control:
@body('Get_files_(properties_only)_-_Templates')?['value']
The code of the Identifier in the template file actions:
@items('Apply_to_each_-_Template_of_WorkingFiles')?['{Identifier}']
We do not even have to change anything in the Send an email action because the array variable will contain all found template files when placed in the Apply to each control:
The email will now contain every found template:
Easy right?! 👍