Power Automate - Send Email to Multiple People Picker Recipients

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:

too-many-actions

Click here to see the email in text form
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.
Warning
If you do not fix this correctly, this mistake could send the same email out over and over again to the same recipient when your people picker field is allowed to have mutliple people set up in SharePoint like this:
people-picker-multiple-selections

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,

easy-add-email-action

  1. Add “Send an email (V2)” in “Office 365 Outlook” group of actions
  2. Click To dropdown
  3. Enter custom value

easy-person-field-email
Then click the lightning bolt near the dropdown and

  1. Click See More
  2. Click on Field name Email - you may have to scroll to find the email value of your people picker field.

easy-2-apply-loops
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
  "type": "Foreach",
  "foreach": "@outputs('Get_items')?['body/value']",
  "actions": {
    "For_each": {
      "type": "Foreach",
      "foreach": "@item()?['Manager']",
      "actions": {
        "Send_an_email_(V2)_Easy_Path": {
          "type": "OpenApiConnection",
          "inputs": {
            "parameters": {
              "emailMessage/To": "@items('For_each')?['Email']",
              "emailMessage/Subject": "You have an incomplete task",
              "emailMessage/Body": "<p>Easy path</p>",
              "emailMessage/Importance": "Normal"
            },
            "host": {
              "apiId": "/providers/Microsoft.PowerApps/apis/shared_office365",
              "connection": "shared_office365",
              "operationId": "SendEmailV2"
            }
          }
        }
      }
    }
  },
  "runAfter": {
    "Get_items": [
      "Succeeded"
    ]
  }
}

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.

Send One Email
You can use this loop to create the appropriate To field so that you can send a single email out to all the recipients. This is beyond the scope of this post, but I have seen other content cover this topic.

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”.

picker-loop

  1. Click on the new action.
  2. Click inside the Select An Output from previous steps * text box.
  3. Click the lightning bolt.
  4. Select the name of the people picker field.

First, add a “Send an email (V2)” action to your new Apply to each loop from the previous step.

to-field-using-multiple-people-picker

  1. Click on your email new action to select it.
  2. In the Parameters section
  3. Click the fx icon.
  4. Click Dynamic content
  5. Click Current item under Apply to each 1
  6. Append ?['Email'] so that the box contains items('Apply_to_each_1')?['Email']
  7. Click Add

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.

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.