Creating a Custom SharePoint News Digest with Power Automate

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.

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:

  1. replace(body(‘CreateHTMLTable’),’&lt;a href=&quot;’,'<a href=”‘)
  2. replace(Outputs(‘Compose2′),’&quot;&gt;’,'”>’)
  3. replace(Outputs(‘Compose3′),’&lt;/a&gt;’,'</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’)

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.

19 thoughts on “Creating a Custom SharePoint News Digest with Power Automate

  1. Can you do this for unread news items in SharePoint? Not sure if flow is that intelligent yet?!

    1. Hi Chris, this would be complex because it would require access to the audit logs. Not easily done with Power Automate.

  2. Is there a way to filter the flow to only return news posts? I got the flow to work, but it returns my site pages in the email as well, not just the news posts.

  3. Hello I copied in your code (by typing it out) for compose 2 as you said but I am getting an error of “Correct to include a valid reference to ‘CreateHTMLTable’ for the input paramter(s” of action ‘Compose2′”

  4. Disregard my comment I figured out they switched ‘createHtmlTable’ to ‘Create HTML table’ so had to include underscores in the code

  5. Great post Steve, this helped me with a few snags I was having. Do you know if there is a way to mimic the webpart that gets all hub news? I haven’t found a way and think I might just need to have a config list that has a list of all sites to grab all news from posted in last 24 hours for daily email digest requirement.

    1. Hi Jon, really good question. I am working on a Flow that uses SharePoint Search to find items. It could be used to get News across all sites with a few changes. Once I’ve finished I’ll write a blog.

      1. Have you done any work on this (using a search to find news items across all sites in a hub)?

        If not, can you show exactly how you filtered on the modified date?

  6. hi there! thanks for the blog post… well I want to know to share the news as it is visible in the news section (means no custom HTML just the SharePoint news style) the “news Digest style” through power Automate + I need to send the news which was created in the one month period.

    1. This isn’t possible without creating custom HTML unfortunately. You can post links to a Teams channel and this will preview the News post.

      1. thanks for your quick reply… yes this could be done through teams but I need to do it through SharePoint online Team site.

  7. Thank you so much for this amazing walkthrough. Would you mind sharing how to center the table within the email? I’m not great with CSS so I haven’t been able to figure it out.

    Thanks

      1. Thank you for the quick reply, I’ve realized since I posted that yesterday that I actually would like to center the entire body of the email. I tried putting a section in to center the body in the CSS compose but it doesn’t work. I’ll keep playing with it though. Thank you again

      2. Thank you, I was able to get it the way I wanted to by using a center tag for the whole page. Thanks again.

  8. Chris – thank you! I tried this and get an error caused by the Filter Query value of formatDateTime(addDays(utcNow(),-7),’yyyy-MM-ddThh:mm:ssZ’) — any thoughts on how to fix? thank you!

  9. Steve

    Thanks for this info. I have been unable to get the filter to work. I removed temporarily and only receive an empty email – figured it would show all news items w/o filter. Used all info provided directly from video and this post. Thanks for any tips.

Leave a comment