web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : y+nKdIPL5kVZ2zcN6CFHmE
Power Automate - Building Flows
Unanswered

(From an excel table) Send Emails to primary contact based on category and cc multiple different secondary contacts respective to the row their in.

Like (0) ShareShare
ReportReport
Posted on 14 Aug 2023 20:26:20 by

I'm new to flow and would appreciate any input on the following: 

 

Using one excel table I'm trying to send an email to my primary contacts based on a category they fall in. This category can multiple different secondary contacts and would need to cc all of them in a single email sending to the primary contact. Below is a general idea of what my flow looks like. 

 

I keep getting errors in the cc field using expression: join(outputs('apply_to_each_3'),'; ')

       I played around with it but keep getting error on how join must pull from an array.

 

Just looking for a general idea on how to go about this. Let me know if you'd like specific details. 

jellybeen2_1-1692044742895.png

 

 

 

 

  • Community Power Platform Member Profile Picture
    on 17 Aug 2023 at 15:04:37
    Re: (From an excel table) Send Emails to primary contact based on category and cc multiple different secondary contacts respective to the row their in.

    Hi @rzaneti

     

    Thanks for your help but this didn't seem to solve the issue. This might provide more context: 

     

    This first apply to each and below expression pull the distinct secondary contacts based on the category. I then use the composed object in my second filter array. The "first" expression however only pulls the first email listed in the excel table that matches the category. Please note my primary and secondary contacts are separate lists. Also, power automate doesn't let me select secondary contacts from an array and says I need to use integer index.

     

    first(body('Filter_array'))?['Secondary contact']

     

    jellybeen2_0-1692284623441.png

     

  • rzaneti Profile Picture
    4,096 Super User 2025 Season 2 on 16 Aug 2023 at 21:20:46
    Re: (From an excel table) Send Emails to primary contact based on category and cc multiple different secondary contacts respective to the row their in.

    Hi @Anonymous ,

     

    The variable may be initialized out of the 'Apply to each' block (and may be placed before it).

     

    The expression will be item()['Secondary contact']. As you won't be initializing the variable inside the loop, Power Automate may not issue the error anymore. 

  • Community Power Platform Member Profile Picture
    on 16 Aug 2023 at 18:08:48
    Re: (From an excel table) Send Emails to primary contact based on category and cc multiple different secondary contacts respective to the row their in.

    What would the expression be then? there isnt an option to choose outputs of filter array and when I manually type one of these expression: outputs/body/item/items(filter_array_2)?['Secondary contact'], it says it cannot select the property and array elements can only be selected using inter index. 

     

    If i try to use item/items, i can't save because of below error. But when I try to add initialize variable to my apply to each loop, it says it must be on the top level. The i wouldnt be able to reference the filter array in my initialize variable because it is after it. 

     

    Flow save failed with code 'InvalidTemplate' and message 'The template validation failed: 'The workflow action 'Initialize_variable' at line '1 and column '10036' references the action 'filter_array_2' of type 'Query': only the actions of type 'foreach' are allowed to be referenced by 'repeatItems' or 'items' functions.'.'.

  • rzaneti Profile Picture
    4,096 Super User 2025 Season 2 on 16 Aug 2023 at 10:59:19
    Re: (From an excel table) Send Emails to primary contact based on category and cc multiple different secondary contacts respective to the row their in.

    Hi @Anonymous ,

     

    The solution above is to extract dynamic values. In your case you will just replace the 'source' variable for the array where you have the filtered Excel records stored (which seems to be 'Filter array 2'). 

  • Community Power Platform Member Profile Picture
    on 16 Aug 2023 at 01:55:24
    Re: (From an excel table) Send Emails to primary contact based on category and cc multiple different secondary contacts respective to the row their in.
    Thank you for the detailed reply! Is there a work around inputting the emails in manually into the value field? The email list that I pull from the excel table is very long and changes every day.
  • Community Power Platform Member Profile Picture
    on 16 Aug 2023 at 01:55:21
    Re: (From an excel table) Send Emails to primary contact based on category and cc multiple different secondary contacts respective to the row their in.
    Thank you for the detailed reply! Is there a work around inputting the emails in manually into the value field? The email list that I pull from the excel table is very long and changes every day.
  • rzaneti Profile Picture
    4,096 Super User 2025 Season 2 on 15 Aug 2023 at 23:49:59
    Re: (From an excel table) Send Emails to primary contact based on category and cc multiple different secondary contacts respective to the row their in.

    Hi @Anonymous ,

     

    Thank you for the additional clarification. Based on your description, we just need to extract the email property from a list of objects (which in this case is the output from 'Filter_array_2').

     

    For this example, I'm using this array of objects (called 'source), from where we will extract the email and allocate in a string with a structure of 'email1; email2; email3', by using the semicolon as separator for each email address:

    rzaneti_1-1692142628851.png

     

    From your end, just replace the 'source' variable for your 'Filter_array_2'.

     

    First, initialize a string variable with empty value. Here you will store the list of emails to be sent (the 'CCs'):

    rzaneti_2-1692142670666.png

     

    Then you can use an 'Apply to each' loop to access the array with the emails (which in your case seems to be the output from 'Filter array 2'), and insert an 'Append to string variable' action inside it, to populate the variable that you created in the previous step. In the value to be appended, insert the dynamic content of the 'Secondary contact' column from your 'Filter array 2' (in the example below, represented by the 'email' column, highlighted in blue). Finally, make sure to include a semicolon and a blank space after the dynamic content (highlighted in green):

    rzaneti_5-1692143028123.png

     

    The output from each loop iteration will look like this, matching to the email, the semicolon and a blank value. 

    rzaneti_6-1692143089333.png

     

    After the loop, you will be able to access the text with all emails, but before it, we need to remove the semicolon and blank space at the end. So we will need to use the following expression:  slice(variables('email_list'), 0, sub(length(variables('email_list')), 2)):

    rzaneti_7-1692143163431.png

     

    This expression will be basically remove the last 2 characters from the string, resulting in the following output:

    rzaneti_8-1692143314172.png

     

    Then you will be able to use it in your Email action 🙂

     

    I'm not sure if it will solve your problem, but feel free to provide more details or bring any other challenges related to the flow.

     

    Let me know if it works for you or if you need any additional help!

    -------------------------------------------------------------------------
    If this is the answer for your question, please mark the post as Solved.
    If this answer helps you in any way, please give it a like.

    http://digitalmill.net/

     

  • Community Power Platform Member Profile Picture
    on 15 Aug 2023 at 18:46:39
    Re: (From an excel table) Send Emails to primary contact based on category and cc multiple different secondary contacts respective to the row their in.

    Sorry for the confusion. Let me start from scratch. 

     

    The excel table I'm pulling from is a long list that has (from left to right): category, relevant info columns, primary contact email (individual), secondary contact email (individual)

     

    from left pic to right pic: 

     

    I'm selecting by category and getting unique categories > apply to each to filter by category and create my html table I'm inputting into my email and also compose objects required to complete next steps > select 2 and compose distinct names selects primary contact, apply to each 2 filters primary contact and composes emails. In my cc field is: first(body('Filter_array_2'))?['Secondary contact'], however, this is only cc'ing the first secondary contact. How can i cc multiple respective secondary contacts that match with the excel rows I pull from? I've tried different routes but lack technical expertise to get it to work.

     

    jellybeen2_2-1692124909438.pngjellybeen2_4-1692124999619.png

     

  • rzaneti Profile Picture
    4,096 Super User 2025 Season 2 on 15 Aug 2023 at 18:19:58
    Re: (From an excel table) Send Emails to primary contact based on category and cc multiple different secondary contacts respective to the row their in.

    Hi @Anonymous ,

     

    Sorry, but I'm not sure if I understood your process. Please, confirm if this is correct:

    1. You pull all rows from your Excel table ('List rows present into a table' action)

    2. You filter these records based on a primary contact/category column (in which action are you filtering it? Does it return only one record or more than one)?

    3. After that, you use the 'Apply to each 3' loop, using the output from step 2 as input (1 or 'N' of records matching to a specific category/column). 

    4. You try to join all of the items from 'Apply to each 3', and this is where you are getting the error. 

     

    If you prefer, you can also share some screens of your actions in expanded view to illustrate the process. 

  • Community Power Platform Member Profile Picture
    on 15 Aug 2023 at 14:59:47
    Re: (From an excel table) Send Emails to primary contact based on category and cc multiple different secondary contacts respective to the row their in.

    Hi @rzaneti

     

    Thanks for the reply. 

     

    My cc column (secondary contacts) is just one email per row. 

     

    The apply to each 3 is to filter my secondary contacts based on primary contact/category. Any suggestions on how I can filter cc column and adding it to array so I can use the join function? 

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2