Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

"Apply to Each" fails to send email when a Dynamic Value is used for the email address

(0) ShareShare
ReportReport
Posted on by 33

I'm trying to generate a reminder email only for items that are NOT complete and in between a reminder date and a due date. It works and sends the email when the email is hard-coded (blah@blah.com) , but fails if I try to use the "Author email" field from the associated SharePoint list.

 

My Power Flow is associated with a SharePoint list.

  1. Get items:
    1. Only items with a "Status" NOT EQUAL to "Complete". "Status" is a column from the SharePoint list.
    2. Filters columns by using "Limit Columns by View". I made sure to include the multiple person/group column, "Author" which I use later for the email.
  2. Condition: Today's date is greater than the "Reminder Date" and less than or equal to the "Due Date".
  3. Switch on "Status": For testing, I am only handling the case where Status equals "Writing Report".
  4. Send an email: This is where I need help. If I hard-code an email address, it sends the emails without error. But if I use the Dynamic Value "Author Email" it errors and fails to send the email. NOTE: The "Apply to each 2" step with "Current item" was generated automatically when I added the Author Email field.

The ERROR:

ExpressionEvaluationFailed. The execution of template action 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@items('Apply_to_each')' is of type 'Object'. The result must be a valid array.
 

1.png

2.png

3.png

  • Verified answer
    v-yetonggu-msft Profile Picture
    on at
    Re: "Apply to Each" fails to send email when a Dynamic Value is used for the email address

    Hi @marmot777 ,

    Please enter the expression manually.

    Do not directly select the 'Author Email' and 'Lead Email' dynamic content.

    This will cause unnecessary loops and flow will report an error.

    vyetonggumsft_1-1714467291184.png

    In addition, I found another problem.

    If your 'Status' is a single-choice column, you should use ’Status Value‘ instead of ’Status‘.

    Like this:

    vyetonggumsft_3-1714468328176.png

     

    item()?['Email']
    join(body('Select'),';')
    join(body('Select_2'),';')
    

     

    Best Regards,

    Sunshine Gu

  • marmot777 Profile Picture
    33 on at
    Re: "Apply to Each" fails to send email when a Dynamic Value is used for the email address

    Hi Sunshine Gu, I need to also CC multiple "Leads" and "Managers" in the same way. How do I expand on  your solution to include groups to CC? I tried the following...with the "To" field Expression filled in as

     

    join(body('Select_2'), ';')
     

    1.png

     

    With the following error:

     

    2.png

     

  • v-yetonggu-msft Profile Picture
    on at
    Re: "Apply to Each" fails to send email when a Dynamic Value is used for the email address

    Hi @marmot777 ,

    1)In the Send an email, we already use the join function to join the email addresses of multiple authors together to send an email to multiple email addresses.

    You can check in the running records whether the ‘To’ of send an email is multiple email addresses separated by ';'.

    2)Also, this is just a test example I'm showing you how to send emails to multiple authors' email addresses.

    If you have other questions, please create a new post and provide more description information, and more people will help you answer it.

     

    Best Regards,

    Sunshine Gu

     

  • marmot777 Profile Picture
    33 on at
    Re: "Apply to Each" fails to send email when a Dynamic Value is used for the email address

    Hi Sunshine Gu, I don't feel like my problem is solved yet because I don't know how to send the email to multiple email addresses. Also, I don't understand your solution enough to compose a clearly written question. Was this your intended solution, or a test case like you said before. 

  • v-yetonggu-msft Profile Picture
    on at
    Re: "Apply to Each" fails to send email when a Dynamic Value is used for the email address

    Hi  @marmot777 ,

    If I solve your problem, please mark my response as a solution so I can help more people who are experiencing this challenge in the future.

    For your new question, you can re-post it on the forum so that more people can see it, which will solve your problem more efficiently.

    Best Regards,

    Sunshine Gu

  • marmot777 Profile Picture
    33 on at
    Re: "Apply to Each" fails to send email when a Dynamic Value is used for the email address

    Also, if this is the solution, what is the most efficient way to add more email addresses to CC to?

  • marmot777 Profile Picture
    33 on at
    Re: "Apply to Each" fails to send email when a Dynamic Value is used for the email address

    With your help, I was able to get the following working and sending emails. Is this the solution, or was this a test and you have something else in mind.

     

    THANK YOU!!

     

     

    Screenshot 2024-04-19 141105.png

  • Verified answer
    v-yetonggu-msft Profile Picture
    on at
    Re: "Apply to Each" fails to send email when a Dynamic Value is used for the email address

    Hi @marmot777 ,

    Please delete Apply to each3 and change Author Email to Author.

    vyetonggumsft_1-1713506481546.png

    Best Regards,

    Sunshine Gu

     

     

  • marmot777 Profile Picture
    33 on at
    Re: "Apply to Each" fails to send email when a Dynamic Value is used for the email address

    I tried both "Author" and "Author email" but ended up with the same error.

    1.png

    2.png

    3.png

  • v-yetonggu-msft Profile Picture
    on at
    Re: "Apply to Each" fails to send email when a Dynamic Value is used for the email address

    Hi @marmot777 ,

    Please carefully check the configuration parameters in 'Select':

    vyetonggumsft_1-1713504136351.png

    Best Regards,

    Sunshine Gu

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

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,645 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow