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 Automate / Scheduled Email Summary
Power Automate
Suggested Answer

Scheduled Email Summary

(2) ShareShare
ReportReport
Posted on by 161
Hi There,
 
I have a SQL View that is filtered to just show late orders...
 
I have created a flow which feeds this information into a sharepoint table, using a SQLID as the unique reference.. Its a recurring flow that runs each evening, so therefore picking up what was not sent by 5pm that evening.
 
I need help sending an email HTML Summary of the new items that are populated after each run should there be any.. And also need to group the entries per customer.
 
My current flow has..
 
>Recurrence
>Get Rows (SQL)
>Apply to each SQL
>>Get Items Sharepoint
>>Condition  length(body('Get_items')?['value']) - True Then
Create Sharepoint Item
& Update Sharepoint Item, so its updates a column back in sharepoint to say that its already be put throuhg the flow.
 
So i believe the data hitting my sharepoint table is correct... But i am struggling creating the HTML applicable data, and ensuring that its only showing the newly generated data and not just all records again.
 
Any help would be appreciated.. Im not familiar with variables etc.
 
Thanks
 
Categories:
I have the same question (0)
  • Suggested answer
    Vish WR Profile Picture
    3,748 on at
     

    The main issue is you’re not isolating only the new items created in the current run, so your email ends up trying to rebuild everything.

    • Create an array variable (e.g. varNewItems) before the loop.
    • After you create/update SharePoint items, append only those records into this array.
    • Then build your email from this array instead of querying SharePoint again.
    For the Email
    • Create a string variable for HTML
    • Loop through varNewItems
    • Add rows like Order ID + Due Date
    Vishnu WR
     
    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 

     
  • Suggested answer
    11manish Profile Picture
    3,333 on at
    Your architecture is already good. The cleanest and most reliable solution is:
    • Detect new SQL records
    • Store only new items in an array
    • Build the email from the array
    • Send email only when the array has records
    This keeps the flow simple, avoids duplicate emails, and scales much better over time.
  • Suggested answer
    Haque Profile Picture
    3,653 on at
    Hi @craig_01,
     
    So you could achieve the flow where you pull data from SQL views and push them in the SP list. Here are the things you can do for rest of your queries:
     
    "And also need to group the entries per customer." - I believe this is something we can cater at SQL view level, can we build the query in the View so that we can retrieve details grouping by customer? - This will ease your manipuation at flow side.
     
     
    "and ensuring that its only showing the newly generated data and not just all records again." - how do you want to set this logic? We have one way - in the SP list we can introduce a column named "EmailSent" keeping value Yes/No (True/False) or a datetime stamp, so when you pull data from View using SQLID/DateTime stamp, you can do filter only for them where EmailSent is false or DateTime check past the current time.
     
     
    "creating the HTML applicable data"
     
    • Once your grouping data is ready, use another loop to iterate over each customer group.
    • For each customer, append an HTML section with the customer name as a header.
    • Inside that section, build an HTML table or list of the orders for that customer.
    A sample could be like this:
    <h2>Late Orders Summary</h2>
    
    <h3>Customer A</h3>
    <table border="1" style="border-collapse:collapse;">
      <tr><th>Order ID</th><th>Order Date</th><th>Amount</th></tr>
      <tr><td>123</td><td>2024-04-25</td><td>$100</td></tr>
      <tr><td>124</td><td>2024-04-26</td><td>$150</td></tr>
    </table>
    
    <h3>Customer B</h3>
    <table border="1" style="border-collapse:collapse;">
      <tr><th>Order ID</th><th>Order Date</th><th>Amount</th></tr>
      <tr><td>125</td><td>2024-04-24</td><td>$200</td></tr>
    </table>
     
    Let's watch a video for email styling.
    If you need other customization in the email, let's read
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • craig_01 Profile Picture
    161 on at
    @Vish WR thanks for you reply, i makes sense from a headline perspective.. See my flow currently attached, i need some more guidance on setting up the variable etc. And how to use the array within the HTML Table.. I know how to create the send email action etc.. Some some other contributors have helpful details on the HTML table creation.
     
    Thanks
     
     
    Doc1.pdf

    Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

  • Suggested answer
    Valantis Profile Picture
    6,735 on at
     
    Here are the steps to set up the variable and build the HTML email.
    Step 1: Initialize variables before your loop
    Add two Initialize variable actions right after your Recurrence trigger:
    - Variable 1: Name = varNewItems, Type = Array, Value = []
    - Variable 2: Name = varHTMLBody, Type = String, Value = (empty)
     
    Step 2: Append new items inside your loop
    Inside your Apply to each, after the Create SharePoint Item action in the True branch, add Append to array variable:
    - Name = varNewItems
    - Value = { "Customer": item()?['CustomerName'], "OrderID": item()?['SQLID'], "DueDate": item()?['DueDate'] }
    Replace the field names with your actual SQL column names.
     
    Step 3: After the loop, check if there's anything to send
    Add a Condition after the Apply to each:
    - length(variables('varNewItems')) is greater than 0
     
    Step 4: Build the HTML in the True branch
    Add a Select action:
    - From = varNewItems
    - Map each field you want as columns
    Then add a Create HTML table action:
    - From = output of Select action
    For grouped by customer, add a Set variable action before the email:
    - Set varHTMLBody to your header HTML + the HTML table output
     
    Step 5: Send email
    Set the Body of Send an email to varHTMLBody.
     
    Haque's HTML template in the previous reply is a good base for the styling. The Create HTML table action generates the table automatically from your Select output so you don't need to hand-code each row.
     

     

    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

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 Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard