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 :
Power Automate - Building Flows
Unanswered

combine email addresses by company and send single email for each company

(1) ShareShare
ReportReport
Posted on by 37

I have a list of email addresses and their associated company name.  I want to combine all the emails for each company into a single string, then send an email to each company.  See image with sample list and desired output.

 

I think this would involve two nested "apply to each" actions but not sure how to put it together.

 

I have the same question (0)
  • ManishSolanki Profile Picture
    15,089 Super User 2025 Season 2 on at
    Re: combine email addresses by company and send single email for each company

    Hi @BBGG 

     

    I have designed a sample flow for you to refer, in this flow I have used separate column for storing Company name but if you are taking Title field for company name then pls replace Company field with Title field:

    ManishSolanki_0-1687490008880.png

     

    1. Firstly, get the list items from SharePoint list using 'Get items' action:

    ManishSolanki_1-1687490113233.png

     

    2. Next, we will create an array of company names present in the SharePoint list using 'Select' action:

    ManishSolanki_2-1687490211314.png

     

    Note: If you are using Title field for company name then replace Company field with Title field:

     

    3. Now, we will store the unique company names in an array variable using expression. In the expression, we will use 'Union' formula to get the unique values from the collection of company names:

    ManishSolanki_4-1687490428038.png

    Expression used to get unique values:

    union(body('Select'),body('Select'))

     

    4. Next, we will iterate on unique company names using 'Apply to each' action & store the value of each iterated item temporarily in 'Compose' action:

    ManishSolanki_5-1687490590094.png

     

    5. Continue inside 'Apply to each' action, add 'Filter array' to filter out the list items or records based on the company name from current iteration:

    ManishSolanki_6-1687490835151.png

     

    6. Next inside the same 'Apply to each' action, add 'Select' action to get only the company email address as a collection from the output of 'Filter array' action:

    ManishSolanki_7-1687490980877.png

     

    6. Finally, add 'Send an email' action to send email to company email address:

    ManishSolanki_8-1687491183985.png

    Expression used in this step:

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

    Pls add the text in email body as per your need.

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

    Thanks

  • BBGG Profile Picture
    37 on at
    Re: combine email addresses by company and send single email for each company

    Hi @ManishSolanki 

    Something is off when we try to duplicate.  Specifically in steps 4-6.  It looks like when we do the "compose" action in step 4 the compose output is coming back as {"PSPL":""}  not simply PSPL .  As a result, step 5 (filter array) and step 6 (select 2 and email) are basically coming back as null.   See our output from Steps 4-6 below.

    PA_combine-email-bycompany.png

  • ManishSolanki Profile Picture
    15,089 Super User 2025 Season 2 on at
    Re: combine email addresses by company and send single email for each company

    Hi @BBGG 

     

    I would request you to pls share the screenshots of the entire flow, that will better help in locating the issue.

     

    Thanks

  • BBGG Profile Picture
    37 on at
    Re: combine email addresses by company and send single email for each company

    Thanks @ManishSolanki - See entire flow with callouts to all the objects.

    PA_combine-email-bycompan2y.png

  • BBGG Profile Picture
    37 on at
    Re: combine email addresses by company and send single email for each company

    @ManishSolanki .  Image from previous post might be too small.  Here is the full flow in parts:  

     

    PA_combine-email-bycompany_1.png

    PA_combine-email-bycompany_2.png

    PA_combine-email-bycompany_3.png

    PA_combine-email-bycompany_4.png

  • ManishSolanki Profile Picture
    15,089 Super User 2025 Season 2 on at
    Re: combine email addresses by company and send single email for each company

    Hi @BBGG 

     

    Thanks for sharing the screenshots of the entire flow 🙂

    There is a common issue in both 'Select' actions, the expression needs to be entered after enabling the action in 'text mode' but not directly in 'Key' box.

     

    To enable text mode, you need to click on the button present on the extreme right side of the 'Map' property:

    ManishSolanki_0-1689173460108.png

     

    Next, enter the expression in the textbox:

    ManishSolanki_1-1689173578631.png

     

    Similarly, do the changes for 'Select 2' action and test the entire flow.

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

    Thanks

  • akgravesen Profile Picture
    3 on at
    Re: combine email addresses by company and send single email for each company

    Thanks for this discussion.  How would I go about adding an attachment to the email being sent?  It seems when I follow this structure and try to add an attachment it adds the attachment multiple times.

  • ManishSolanki Profile Picture
    15,089 Super User 2025 Season 2 on at
    Re: combine email addresses by company and send single email for each company

    Hi @akgravesen 

     

    Could you pls provide more details? If possible, pls share the screenshots of the flow in edit mode (mask sensitive info).

     

    Thanks

  • PeerapongS Profile Picture
    16 on at
    Re: combine email addresses by company and send single email for each company

    Hi @ManishSolanki 

     

    I've followed your flow but I got error details: Parameter 'To' cannot be null or empty.
    clientRequestId: 6003b418-c838-49b0-ae54-f878244569f1 at send email action.

     

    Here is my steps

    PeerapongS_0-1720065359408.png

     

    PeerapongS_1-1720065388617.png

     

    Here is my excel data

    PeerapongS_2-1720065542859.png

     

    Please help to solve this error

     

    Thanks,

    PeerapongS

     

  • ManishSolanki Profile Picture
    15,089 Super User 2025 Season 2 on at
    Re: combine email addresses by company and send single email for each company

    Hi @PeerapongS 

     

    Pls modify "Select" action. You need to click on button on the right side 'Switch Map to text mode'. Once you click it, you need to enter the below expression in the textbox:

    item()?['Email']

     Same way, pls modify "Select 2" action.

     

     

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

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

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 535 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 348 Moderator

#3
developerAJ Profile Picture

developerAJ 262

Last 30 days Overall leaderboard