Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Unanswered

Slow running of Apply to each only joining data

(0) ShareShare
ReportReport
Posted on by 37

Hello everyone, I need some help in speeding up an automation, in brief what the automation does is:

  • Receive an email and clean it up
  • Retrieve a list of email addresses, <3400 emails
  • Build JSON to email 100 addresses at a time

Our email provider have a limitation in that you can only send emails to 100 email addresses at a time and building this list is where the Flow is slowing down (Apply to each):

Garth_0-1650921522278.jpeg

 

To explain the above, I get the 100 email addresses in the HTTP command, Parse them to get them out and then build the array of 100 email addresses and email content.

Anyone got any thoughts or suggestions how I might speed up this process?

  • Garth Profile Picture
    37 on at
    Re: Slow running of Apply to each only joining data

    Garth_0-1651697679080.png

    Garth_1-1651697694982.png

     

    and the "Outputs" is just a variable where I have constructed my HTML to send.

     

    In testing, my previous run would take between 18 - 20 minutes, now it has taken between 2 - 4 minutes.

  • VictorIvanidze Profile Picture
    12,214 on at
    Re: Slow running of Apply to each only joining data

    HI @Garth,

    please show the fields of your Select actions.

     

  • Garth Profile Picture
    37 on at
    Re: Slow running of Apply to each only joining data

    @takolota 

    Thanks for the help, I took a step back and took a copy of the original flow and simply remove the sending API call and tested with that and your code worked and much quicker.

     

    To test on the production flow I have branched from the HTTP 2nd call and done the building of the body for the API call and will see how it runs next time it runs.

     

    thanks also go to @VictorIvanidze for their help as well,  I will report back when the production flow runs.

  • Garth Profile Picture
    37 on at
    Re: Slow running of Apply to each only joining data

    Thanks @takolota for the speedy response, the reason I am using a compose is I am trying to test the select action in a test environment without running the production flow that needs to work.

     

    I will try again.

  • takolota1 Profile Picture
    4,859 Super User 2025 Season 1 on at
    Re: Slow running of Apply to each only joining data

    @Garth 

    I don't know why you are adding all those Compose actions. If you just use the parameters I listed

    ?['_embedded']?['contacts']

    after the HTTP body in an expression, then it gets the right array.

    Here, I copied the HTTP sample you gave us into a Compose action (You do not need to use a Compose action as you have the actual HTTP action) and I set up the Select action the way I described. These were the successful results.

    SelectHTTPEx2.png

    SelectHTTPEx.png

  • Garth Profile Picture
    37 on at
    Re: Slow running of Apply to each only joining data

    @VictorIvanidze I am trying to get this to work just like your example however simply pasting the JSON returned into a Compose does not allow my select to work as it sees it as a string.

     

    Garth_0-1651631943578.png

     

  • Garth Profile Picture
    37 on at
    Re: Slow running of Apply to each only joining data

    @takolota that is awesome, but it didn't work.

     

    I am now just trying a test similar to what @VictorIvanidze posted above, but I cannot get the Select to work.

     

     

  • takolota1 Profile Picture
    4,859 Super User 2025 Season 1 on at
    Re: Slow running of Apply to each only joining data

    @Garth 

     

    Okay I’ve done something similar to this then.

     

    If each recipient has a different JSON body in that array, then you can switch that Select action back to the original format with the table view. Make sure you are using the correct expression in the From field

    body('HTTP')?['_embedded']?['contacts']

    Put email on the left side of the 1st row & dynamic_warning_content on the left side of the 2nd row.

    Then click in the right side of the 1st row next to the email cell to open the dynamic content window, go to the expressions tab & put in this expression

     

     

    item()?['email']

     

     

    Then go below that to the cell next to the dynamic warning cell & insert the static content for the dynamic warning content value of the HTTP request.

    That should give you the array of JSON objects required for the recipients field you showed above in the HTTP request without using any loops. So it will process everything in under a second.

  • Garth Profile Picture
    37 on at
    Re: Slow running of Apply to each only joining data

    @takolota to send the email I have to build the JSON to send a HTTP API request to the email provider to send the email to the 100 people. To do this I have to format each of the "records" a particular way as specified above.

     

    dynamic_warning_content is actually a variable in the email template that I fill with the "Outputs" text which is the same for each email address. Here is an excerpt of what the Post Body looks like that I am building (only includes one (1) email, but there could be up to 100 rows for recepient):

     

    {
     "list_id": 111111,
     "message_id": 1111111,
     "type": "email",
     "group_name": "Group Name Text",
     "subject": "Subject text",
     "recipients": [
     {"email":"email@server.com","dynamic_warning_content":"<body><p></p><div style='background-color:#F8E7E8; width:100%; border-style:solid; border-color:#CA3E47; border-width:1pt; padding:2pt; font-size:10pt; line-height:12pt; font-family:'Calibri'; color:Black; text-align:left'></div><br><p></p><div><div class='ocaemailbody'><div><div><strong>CANCELLATION - Yelarbon and Goondiwindi - fire as at 4:22pm Friday, 22 April 2022</strong></div><div>&nbsp;</div><div>This fire is now extinguished.</div></div><div>&nbsp;</div><div><strong><span style='color:#FF0000'>Location Data:</span> </strong></div><div>&nbsp;</div><p>- <strong>QFES Regions:</strong>&nbsp;3 South Western Region</p><p>- <strong>Councils:</strong>&nbsp;Goondiwindi Regional Council</p><p>- <strong>Suburbs:</strong>&nbsp;Billa Billa (4390), Brush Creek (4387), Bybera (4387), Callandoon (4390), Glenarbon (4385), Goondiwindi (4390), Inglewood (4387), Kindon (4390), Kurumbul (4388), Whetstone (4387), Wondalli (4390), Wyaga (4390), Yelarbon (4388)</p></div></div></body>"}
     ]
    }

     

    Thus this is reason I am trying to find a way to do the "Append" quicker as this is the thing slowing down my automation.

  • takolota1 Profile Picture
    4,859 Super User 2025 Season 1 on at
    Re: Slow running of Apply to each only joining data

    @Garth 

    Where is “dynamic_warning_content” coming from?

    I don’t see it in the HTTP data you listed earlier and I don’t see any other actions in you flow that reference other data.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,670 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow