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/