Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Getting multiple emails due to Apply To Each

(0) ShareShare
ReportReport
Posted on by 364

Hi there,

 

I have the following flow:

EpicTriffid_2-1695994775736.png

 

EpicTriffid_1-1695994492482.png

 

In short, I pull items from an SP list, filter them for only dates in the future, then will send an email a x days before the listed date, make a table and email that to a particular person. However, it sends me five emails, one for each of the filtered rows coming out of Filter Array.

 

When I tried to take this out of the Apply to Each I get the following error :

 

Unable to process template language expressions for action 'Condition' at line '0' and column '0': 'The template language function 'split' expects its first parameter to be of type string. The provided value is of type 'Null'.

 

I think this refers to the condition, where I've had to convert a string to a date to compare it to utcNow. That looks like:

 

formatDateTime(parseDateTime(concat(split(item()?['FSAGDate'], '/')[2], '-', split(item()?['FSAGDate'], '/')[1], '-', split(item()?['FSAGDate'], '/')[0])), 'yyyy-MM-dd')

 

I can only assume the reference to FSAGDate in here (my string that needs to be converted to a date) is somehow not being read properly. 

 

I thought I finally had this working, but now I get 5 emails!

  • Verified answer
    EpicTriffid Profile Picture
    364 on at
    Re: Getting multiple emails due to Apply To Each

    Got it! Thanks @Pstork1!

     

    I got it working like below:

     

    EpicTriffid_2-1695996827340.png

     

    EpicTriffid_4-1695996865470.png

     

  • Verified answer
    Pstork1 Profile Picture
    66,864 Most Valuable Professional on at
    Re: Getting multiple emails due to Apply To Each

    If you are going to create an HTML table then that is a string and you want to append it to a string, not an array.  Then you can just add the string to the body of the email and it should process as HTML tables.

     

    If you only want one table then append the data to an array and then create the HTML table from the array after you exit the loop.

  • EpicTriffid Profile Picture
    364 on at
    Re: Getting multiple emails due to Apply To Each

    Hi @Pstork1 

     

    Great! So I've gotten this far:

    EpicTriffid_0-1695995739056.png

    EpicTriffid_1-1695995766167.png

    But can't quire figure out how to use the variable in my email. And if I did, would it still appear as an HTML table?

  • Pstork1 Profile Picture
    66,864 Most Valuable Professional on at
    Re: Getting multiple emails due to Apply To Each

    You need to use a second condition to check whether the string or array contains anything before sending the email.  If its blank or empty then don't send the email.

  • EpicTriffid Profile Picture
    364 on at
    Re: Getting multiple emails due to Apply To Each

    Thanks @Pstork1 

     

    I had thought about doing that, putting the email outside of the loop, but my logic tells me that then if the condition equates to false, it would still send an email, but with nothing in it?

  • Pstork1 Profile Picture
    66,864 Most Valuable Professional on at
    Re: Getting multiple emails due to Apply To Each

    Since you are processing 5 rows you need the loop. The trick is to accumulate the information while you are in the loop by appending it to a String or Array and then sending the email with the accumulated information once you exit the loop.

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492