Today, look at a widespread mistake people make while developing their Flows. The question that I see in the forums is always something like this. “My Flow is sending multiple emails when I want only one. How to send only one email?”
This isn’t a problem with Power Automate per se but with the strategy used, so today, let’s understand the problem and how to fix it. Once you know the problem, I’m sure the solution will make sense before I explain it, so let’s do it.
Let’s look at an example to understand the issue better. Let’s say we have a Flow that sends an approval Flow to multiple people and gets the responses. After we get the responses, we want to send the result of the approval and all comments to the person that asked for it. You start building the Flow with the approval action and then add a “Send email” action.
Then you start adding the email and the Flow changes to an “Apply to each” action , and you continue writing the email.
Looks good, you test it with your email as an approver, and all looks good. After this, you add the multiple people that need to approve and start getting complaints from people who get various emails (one per approver). The issue is that Flow will run the “Send email” action per reply, which will send per approver. If you have only one, it will send only one email, but if you have multiple, it will send multiple emails.
The solution is easy, but I hope you understand the issues. If you’re getting multiple emails, always check the action of sending them and if it’s inside a loop. If it is, then you need to pull it from inside the “Apply to each” action to the outside.
Let’s see how to do that.
The solution, as mentioned before, is simple. We need to get the “Send email” action outside the “Apply to each” action. Let’s see how to fix the problem above by removing the “Apply to each” action and using another action that can build a lovely table with the results. It’s called the “Create HTML table” action, and it looks like this.
This action will get an array and build a table with our defined results. Notice that the left part of the columns where you can see “Name”, “Response” and “Comment” was defined by us, so you can put any text that makes sense to you. After this, you can use the same “Send email” action as follows:
Now you can have an email with all the answers (regardless of how many) in the same email.
The “Approval” action has elements that contain some of the information like the “Outcome” or the “Response summary,” but they won’t provide you with a detailed view like above. If you want only the final result, these may be enough, so explore them to see if they fit your needs.
The issue is not on Power Automate but how we use it. Since Power Automate does some changes for us, like adding “Apply to each” action when needed (it’s a fantastic feature, don’t get me wrong), we may not notice this change and result in issues like these.
If something happens multiple times, chances are excellent that they are within an “Apply to each” action, so check your Flows and see if one was added without noticing it.