Scenario: you have a SharePoint List where a field with 'Person or Group' having multiple entries is selected. you want to send a mail to all the people entered in that field. However, currently that field is not supported in Microsoft Flow.
Final step is send a Mail. using 'Send an email' action of O365 account. In the "TO" field it will be the 'FinalStringAttendees' variable. Rest of the body you can enter the way you want.
Steps on How to get multiple Entries from 'Person or Group' field in SharePoint List and send a single mail to them.
In This example, I have a simple SharePoint List for Training Registration. Where in the Attendees field multiple people can be selected based on the Nominations. So below we have a field 'Attendees' as 'Person or Group' where 'Allow Multiple Selections:' is selected as "Yes"
- I am Triggering MS Flow when a new item is created in the Training Registration SPO List.
- Next Step adding 'Get Item' action and fetching the item created via its 'ID'
- Next Step adding 'Data operations - Select' action. (this will take only an Array value as input)
- as the output of 'Get Item' will be an array, but I need only the attendees from that New Item created, in 'Select' Action 'From' (input for select) will be the 'Attendees' Field.
- Map Key 'Attendees' to Value 'Attendees Email' (as only email can be used to send a mail.)
- Next we will use 'Initialize Variable' action. I named it as 'OriginalArrayAttendees'. Type as 'Array' and Value will be the Output from previous 'Select' action, we get only the Attendees Mail address in the array variable.
- Next we will again use 'Initialize Variable' action. I name it as 'FinalStringAttendees'. Type as 'String' and Value as blank at this stage.
Now we need to put all the Email addresses into a single variable separated by semi-colon (;)
- Next Step -> Add 'Apply to each' where the output of variable 'OriginalArrayAttendees' is entered.
- from that array, we need to concat all the email addresses with a semi-colon, so we add a 'Data operations - Compose' action and in expression enter "concat(item()?['Attendees'],';')". Pls. Note: Attendees in the concate is the 'Map Key' you gave in the above 'Select' action.
- Next step, we need to append the values in a single String variable which is 'FinalStringAttendees'. Pls. Note: If you do not see the variable in 'Dynamic Content', select 'Expression' and type " variables('FinalstringArray') " [ without double quotes]
- Finally use 'Set Variable' action to get the concatenated string of all email addresses in variable so that it can be used out of the 'Apply to each' loop. Value of 'FinalStringAttendees' will be Output of 'Compose 2' action where we are appending all the values.
Final step is send a Mail. using 'Send an email' action of O365 account. In the "TO" field it will be the 'FinalStringAttendees' variable. Rest of the body you can enter the way you want.