Power Automate - Send Email to Multiple People Picker Recipients
Overview
If you want to send an email to people in a multi-person field from the output from the SharePoint Get Items action, Power Automate says, great, let’s just loop through your list of people. However, you can easily inadvertently wire up the apply-to-each to your get SharePoint items
output and end up with 100 x 100 = 10,000 actions which is over the current low limit for many tenants. This will send an email out. I received this from one of our clients from a Flow someone else had written:
Your flow is running too many actions
Power Automate
Your flow is running too many actions
Your flow has exceeded its Power Platform Requests (https://aka.ms/pa-ppr) limit in the past 24 hours. If this high usage persists, your flow actions may get throttled and slowed down. Power Platform Requests used: 10318, Power Platform Requests transition limit: 10000.
Flow name: Manager's reminder
View Detail Markdig.Syntax.Inlines.HtmlEntityInline
One of the following is causing the problem:
• There's a design issue that's resulting in excessive actions. Viewusage analytics to view execution trends.
• The Power Platform requests transition limit is insufficient for your usage.
Here are a few recommendations:
• If you have 'do until' or 'apply to each' loops in your flow, see if you can reduce the number of loop iterations, possibly by retrieving fewer items to iterate through.
• Many connectors have 'filter query' and 'top count' parameters that can be used to reduce the number of items retrieved.
• If you have a scheduled flow that runs frequently, consider reducing the frequency. Many flows that run once per minute could be revised to occur less often.
• Use process mining to analyze your flow and improve the efficiency. SeeProcess Mining overview.
Assign "Power Automate premium" plan to the owner of the flow. Seetypes of Power Automate licenses.
Easy Way - Let Power Automate Create the Loops
If you’re starting fresh or can start over, Power Automate does a decent job of creating the appropriate loops.
After adding the Get SharePoint Items action returning a multi-value people picker,
- Add “Send an email (V2)” in “Office 365 Outlook” group of actions
- Click
To
dropdown - Enter custom value
Then click the lightning bolt near the dropdown and
- Click See More
- Click on
Field name Email
- you may have to scroll to find the email value of your people picker field.
Power Automate adds two “Apply to each” loops and “helpfully” renames them “For each”. One loops through all the Get items values, and the other loops through each person. Fill in your subject, body and continue on.
Here is a look at the underlying json code in Code View
|
|
Hard Way - Add Email Action to Existing Loop
What if adding the email action comes later in the development process, and you have a bunch of actions inside the loop that you would rather not recreate? If you want to use a multiple-value people picker as the To, CC or BCC fields of the O365 Send email, you must roll your own loop to break out the managers or whoever is in your people picker.
1 Add an Apply to each
Action
Put an Apply to each
action into your existing loop. If your outer loop is already called “Apply to each”, this will be named “Apply to each 1”.
- Click on the new action.
- Click inside the
Select An Output from previous steps *
text box. - Click the lightning bolt.
- Select the name of the people picker field.
2 Wire up the To
field
First, add a “Send an email (V2)” action to your new Apply to each
loop from the previous step.
- Click on your email new action to select it.
- In the
Parameters
section - Click the
fx
icon. - Click
Dynamic content
- Click
Current item
underApply to each 1
- Append
?['Email']
so that the box containsitems('Apply_to_each_1')?['Email']
- Click Add
Entertaining Way - Copilot
I tried using Power Automate’s built-in Copilot to add the email a couple of different ways, and the results were … interesting. It blew up the connection information in the Get Items action, and in general was somewhat amusing. This should improve with time. My prompts probabaly need improvement too.
Trojan Horsing Around
This is one more little “gift” from Power Automate that I could do without, an extension of the 7 Reasons Why Flow is Annoying post that I wrote last month. Another such gift is that the SharePoint Get Items looks like it will give you all the items by default, but my reality is just 100 items. You can override this up to 5000 items after which you need to page through the items via multiple calls. I have screen shots for this and hope to share soon.