“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:
Since you can handle 500 emails at once, the chunkSize will be 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.
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.
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.
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…
…join them with the semicolon, and use them to send the email.
Then increment the variable to skip the already processed 500 emails.
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.