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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Send e-mail to various...
Power Apps
Answered

Send e-mail to various on condition

(1) ShareShare
ReportReport
Posted on by 142
Hello,
I have a collection where one column contains an e-mail address, could be different for any rows. From this collection I am making a table which is in the body (below code)
 
What I want is to send e-mail to every unique address which occur in the collection with filtered rows with that address in the E-mail Column.
 
What is the best way to do it? Thank you
 
Office365Outlook.SendEmailV2(
    "miro.zak@xxxx.com";
    "Schválené přesčasy dne "&Today()&" - týdenní";
    "
    <table>
        <tr>
            <th>KT</th>
            <th>Os. číslo</th>
            <th>Pracovník</th>
            <th>Hodiny</th>
            <th>Středisko</th>
            <th>Práce v noci</th>
            <th>Důvod</th>            
            <th>Stav</th>
        </tr>
        "&
        Concat(
            colSchvalT;
            $"<tr>
                <td>"&TextCanvas8_5.Text&"</td>
                <td>"&Subtitle5_5.Text&"</td>
                <td>"&Title5_5.Text&"</td>
                <td>"&Text6_3.Text&"</td>                
                <td>"&TextCanvas11_5.Text&"</td>
                <td>"&Text27.Text&"</td>    
                <td>"&Text7_3.Text&"</td>                
                <td>"&If(
                Radio1T.Selected.Value = "Ano"; "Schváleno"; "Zamítnuto"
                )&"</td>
            </tr>
        ")&"
    </table><p>
"&Text14_6.Text&"<br>
Bloky: "&Concat(cbxBlokCisloT.SelectedItems; Value; "T, ")&"T<br><p>
"
);;
Categories:
I have the same question (0)
  • Suggested answer
    WarrenBelz Profile Picture
    155,838 Most Valuable Professional on at
    I am not sure what you are doing in the email body, so I copied the code for the moment. If you want to send an email to each unique email address in your collection, you would do this
    ForAll(
       Distinct(
          YourCollection;
          EmailAddressColumn
       ) As _Mail;
       Office365Outlook.SendEmailV2(
          _Mail.Value;
          "Schválené přesčasy dne " & Today() & " - týdenní";
          "
             <table>
                <tr>
                   <th>KT</th>
                   <th>Os. číslo</th>
                   <th>Pracovník</th>
                   <th>Hodiny</th>
                   <th>Středisko</th>
                   <th>Práce v noci</th>
                   <th>Důvod</th>            
                   <th>Stav</th>
                </tr>
          " &
             Concat(
                colSchvalT;
                $"<tr>
                   <td>" & TextCanvas8_5.Text & "</td>
                   <td>" & Subtitle5_5.Text & "</td>
                   <td>" & Title5_5.Text & "</td>
                   <td>" & Text6_3.Text & "</td>                
                   <td>" & TextCanvas11_5.Text & "</td>
                   <td>" & Text27.Text & "</td>    
                   <td>" & Text7_3.Text & "</td>                
                   <td>" & 
                   If(
                      Radio1T.Selected.Value = "Ano"; 
                      "Schváleno"; 
                      "Zamítnuto"
                   ) & "</td>
                </tr>
                " ) & "
             </table><p>
          " & Text14_6.Text & "<br>
          Bloky: " & 
          Concat(
             cbxBlokCisloT.SelectedItems; 
             Value; 
             "T, "
          ) & 
          "T<br><p>"
       )
    );;
     
    Please Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like
    Visit my blog
    Practical Power Apps    LinkedIn  
  • Suggested answer
    Valantis Profile Picture
    6,735 on at
     
    The cleanest approach is to group your collection by email address, then loop through each unique email and send one email per group.
     
    Use GroupBy to get unique email addresses, then ForAll to send each email with the filtered rows for that address:
    ForAll(
        GroupBy(colSchvalT, "EmailColumn", "Rows"),
        Office365Outlook.SendEmailV2(
            EmailColumn,
            "Schválené přesčasy dne " & Today() & " - týdenní",
            "<table><tr><th>KT</th>...headers...</tr>" &
            Concat(
                Rows,
                "<tr><td>" & KT & "</td>...columns...</td></tr>"
            ) &
            "</table>"
        )
    )
    Replace EmailColumn with the actual column name that holds the email address in your collection, and replace the column references inside Concat with the actual field names from colSchvalT (not control references like TextCanvas8_5.Text, use the data field names directly).
     
    Note: your current code references gallery control text properties (TextCanvas8_5.Text, Title5_5.Text etc.). Inside ForAll these won't work you need to reference the data fields from the collection directly.
     

     

    Best regards,

    Valantis

     

    ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/

    💼 LinkedIn

    ▶️ YouTube

  • Verified answer
    Kalathiya Profile Picture
    2,456 Super User 2026 Season 1 on at
     
    You can simply achieve this by first getting the distinct email addresses from your collection and then using a ForAll() loop to send one email per unique address.


    Inside the loop, filter colSchvalT for the current email address and build the HTML table only with those records. This way each recipient receives only their relevant rows, even if the collection contains multiple email addresses.

    Try like this:

    ForAll(
        Distinct(colSchvalT; EmailColumn) As _email, //EmailColumn - Update with your email column
    Office365Outlook.SendEmailV2(
        _email.Value;
        "Schválené přesčasy dne "&Today()&" - týdenní";
        "
        <table>
            <tr>
                <th>KT</th>
                <th>Os. číslo</th>
                <th>Pracovník</th>
                <th>Hodiny</th>
                <th>Středisko</th>
                <th>Práce v noci</th>
                <th>Důvod</th>            
                <th>Stav</th>
            </tr>
            "&
            Concat(
                Filter(colSchvalT; EmailColumn = _email.Value);
                $"<tr>
                    <td>"&TextCanvas8_5.Text&"</td>
                    <td>"&Subtitle5_5.Text&"</td>
                    <td>"&Title5_5.Text&"</td>
                    <td>"&Text6_3.Text&"</td>                
                    <td>"&TextCanvas11_5.Text&"</td>
                    <td>"&Text27.Text&"</td>    
                    <td>"&Text7_3.Text&"</td>                
                    <td>"&If(
                    Radio1T.Selected.Value = "Ano"; "Schváleno"; "Zamítnuto"
                    )&"</td>
                </tr>
            ")&"
        </table><p>
    "&Text14_6.Text&"<br>
    Bloky: "&Concat(cbxBlokCisloT.SelectedItems; Value; "T, ")&"T<br><p>
    "
    ));;
    ---------------------------------------------------------------------------
    Glad it helped 🙂
    If this fixed your issue,
    please click “Does this answer your question?” to mark it as verified so others can find the solution easily.
    A Like 👍 is always appreciated, and I’m around if you need more help @Kalathiya
  • JM-14081323-0 Profile Picture
    142 on at
    Many thanks to all,

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard