Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Triggers
  • Resources
  • ABOUT ME
  • Get help with your flow
Menu

Split email recipients into batches of 500 with Power Automate flow

Posted on October 5, 2022October 5, 2022 by Tom

“I need to send an email to thousands of users but Exchange allows me to use only 500 recipients for an email, how can I split them into batches of 500 with Power Automate?”


If you’re sending emails to individual recipients, you might encounter the Exchange limit. There’s a maximum number of recipients for each email that’s set to 500 by default. If you want to send the same email to more recipients, you’ll have to either increase the limit (up to 1000), or split it into multiple emails. This post describes the second option – how to split the recipients into smaller batches of 500.

Create an array with the emails

The first step is to convert the email addresses into an array. If it’s a list of semicolon separated emails, split(…) it by the semicolon character, e.g.

split(<list of emails>, ';')

If it’s an array of objects, e.g. SharePoint items, then ‘Select’ only the email addresses.

Updated Oct 2022: Use the chunk(…) expression

Power Automate has a new expression chunk(…) that’ll split an array into pieces. It has two parameters:

chunk(<array>, <chunkSize>)

Since you can handle 500 emails at once, the chunkSize will be 500:

chunk(body('Select'),500)

The expression will split the array into multiple arrays of arrays – loop through the chunks, join(…) the emails addresses in each of them and send the email.

And that’s it. Much easier than the original approach which you can still see below using the skip(…) and take(…) concept.

The old approach: Take a piece of an array

For the actual split into batches you’ll need the skip(…) and take(…) expressions.

Take(…) expression

The take(…) expression will take the specified amount of items from an array. The array is the first parameter, number of items to take is the second one. For example, to take 500 items (emails) from an array:

take(<array with emails>, 500)

Note: <…> is a placeholder, replace it including the < and >.

But this will always take the first 500 emails. To process all the emails you must always skip those that were already processed. That’s what the skip(…) expression will do.

Skip(…) expression

The skip(…) expression will skip items in an array. You enter the array as the first parameter and the number of items to skip as the second one, e.g.

skip(<array with emails>, 10)

Note: <…> is a placeholder, replace it including the < and >

The expression above will skip the first 10 emails and return the rest. But here you don’t have a fixed number of emails to skip. At first you want to skip 0 and process the first 500, then skip that 500 and take another 500, followed by skipping 1000 and taking another 500. That’s why you’ll need a number variable – let’s call it var_processed and set it to 0.

This variable will serve as a counter of the processed emails.

Process the batches of 500 emails

As already mentioned, you don’t want to take always the same 500 emails. You want to move in the array.

Power Automate split email recipients

That can be done using the same expression while changing the number of emails to skip. That means a loop with the ‘Do until’ action. Keep moving in the array until the number of processed items (var_processed) is greater or equal to the count of all emails (length(…)).

In each loop take the next 500 emails…

take(skip(body('Select'),variables('var_processed')),500)

…join them with the semicolon, and use them to send the email.

join(take(skip(body('Select'),variables('var_processed')),500),';')

Then increment the variable to skip the already processed 500 emails.

Summary

If you’re sending an email via Power Automate to more than 500 recipients, you’ve got two options. You can either increase the limit (if you’ve got administrator permissions and if 1000 is enough) or you’ll have to split it into multiple emails. Using a loop, variable, and the take(…) and skip(…) expressions you can split the recipients into batches, and process them within the default limitations.

Or you can use the new expression chunk(…) and split it in a single step.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

2 thoughts on “Split email recipients into batches of 500 with Power Automate flow”

  1. Tobi says:
    January 8, 2023 at 6:57 pm

    I have two questions:

    1) What did you write for the join expression.
    2) I am experience errors at the join stage.

    Error Discription:
    The ‘inputs.parameters’ of workflow operation ‘Send_an_email_from_a_shared_mailbox_(V2)’ of type ‘OpenApiConnection’ is not valid. Error details: Input parameter ’emailMessage/Bcc’ is required to be of type ‘String/email’. The runtime value ‘”{\”Email\”:\”2367002@***.com\”};

    Reply
    1. Tom says:
      January 26, 2023 at 2:48 pm

      Hello Tobi,
      check the ‘Select’ action configuration, in your case it seems to return an object, but you want to return only the single value ‘… Email’.

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


There's also the HTTP requests to SharePoint cheat sheet to help you overcome limitations of some standard actions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with 1000s of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes