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.https://www.youtube.com/embed/JQ1Wb_14xGI?version=3&rel=1&showsearch=0&showinfo=1&iv_load_policy=1&fs=1&hl=en&autohide=2&wmode=transparent
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.
Code Snippets:
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=”‘)
- replace(Outputs(‘Compose2′),’">’,’”>’)
- replace(Outputs(‘Compose3′),’</a>’,'</a>’)
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.
Expression code:
- formatDateTime(addDays(utcNow(),-7),’yyyy-MM-ddThh:mm:ssZ’)
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.
About the Author:
In 2011 I started Canterbury Business Solutions with two business partners. We build solutions on the Microsoft stack, usually around SharePoint, .NET and SQL Server. Our business is built on experience and technical expertise built up over nearly 25 years in the IT industry.
In March 2015 we renamed our business to Stratos Technology Partners to signify the growth of our business outside of our home town and the strength of the partnerships we have with our clients.
On the 1st January 2017 I was received my first Microsoft MVP award for Office Apps and Services. Thank you to everyone who helped make this happen for me!
This blog is part of SharePoint Week. For more great content, click here
Reference:
Knutson, S. (2021). Creating a Custom SharePoint News Digest with Power Automate. Available at: https://steveknutson.blog/2021/05/28/creating-a-custom-sharepoint-news-digest-with-power-automate/ [Accessed: 30th August 2021].