Microsoft provides a couple of ways to send out an update or digest email. You can use a simple Alert on the site pages library or use the built in News Digest feature to manually send a digest of selected articles. Sometimes you may need to create a custom solution and Power Automate is the right tool for the job.
In this video I demo how to create a custom email digest, using a few Power Automate steps. This is a little more advanced the the template based solutions. I’ve included the code snippets from the video in this blog.
The workflow shown in the video uses the following steps, starting with a ‘Recurrence’ step, which is created when you create a Scheduled Flow from Power Automate studio. This step can be used to configure the frequency at which the Flow runs e.g., daily, weekly, etc.
HTML Formatting compose steps. Note that each Compose step uses the previous step as it’s input data. Use the Expression feature to add the code, rather than copying it in directly:
- replace(body(‘CreateHTMLTable’),’<a href="’,'<a href=”‘)
If you’re not a CSS guru, copy the CSS from this blog to style the table: Power Automate HTML Table Styling and Formatting (tachytelic.net)
Use the Send Email v2.0 action to compose the email and click the ‘</>’ button to change to HTML format.
In the body, put the Output CSS first and then the final compose Output. These combined create and format the table.
OData filtering can be used to limit results in the Get Files (Properties Only) step. This example, shows items created in the last 7 days.
This Microsoft article has more detail on using OData Filtering in Power Automate.
Running the workflow generates and email from the template with a line for each News post.
The final step in the process is to format the email to meet your design requirements using HTML code in the email template and CSS. You can include header images, published dates and other metadata values.