Forum Discussion
How to Send an Email when added a News Post in SharePoint Online site
Can you post some Pointers on how to do this please?
Thanks
Martin
Hi Mbryant705, sorry I realised I completely forgot to follow up on this post, so also apologies to everyone else involved in the thread.
In a very simple Flow, I can send an email notification when a news item is published. There are a couple of things to be aware of:
- Site Pages won't normally appear in the list of libraries in the trigger, therefore you need to select "Enter a custom value" and then type in Site Pages
- The published state of a document is held within a metadata field called "Promoted state". 1 = in Draft, 2 = Published. If it's a standard site page, not a news item, the Promoted state will be 0.
I can create a condition so that if the Promoted state = 2 (News Item is published) then I can send an email to the required user(s). I can alternatively use the Flow actions to send out a push notification, send a message to Teams etc however you want to get your notification out.
An example Flow is attached to this post. I hope that helps.
- KevinO1984Apr 18, 2019Copper Contributor
Hi Matt Weston thank you for the info, this worked for me to send notifications, but I wanted to ask if you knew a way to add the functionality of adding the content of the news post to the email you send, similar to the way it sends when you use the "send by email" option at the top of the News post page after you publish it?
I can use the "description" dynamic content from the original trigger to put the text into the email, but if there are any images or other things added, that doesn't cover it.
Thanks in advance!
- Matt WestonApr 18, 2019Iron Contributor
Hi KevinO1984 that's a great question and a good extension of what we've already done.
As my trigger is "When a file is created or modified (properties only)" I'm able to see the properties of the page coming back. If I've used another trigger, I'll need to use the action "Get File Properties" to get the same info.
There are two properties which I could use to add some more info to my email:
- Banner Image URL
- Description
Banner Image URL will take the image url of the image which I have assigned as the header of my news page. If I have no header, this field will be populated with the first image that it finds on the page. This is how the rollup image to the news web part works. You can take this URL and use it within HTML in our email.
The Description takes the first paragraph from the news item, so again you can use this to add into your email. I don't think there's a native way of grabbing the entire news article from the properties as it doesn't get tagged as metadata, but I'll have a look to see if there are other options which we can explore.
- fvp11Nov 27, 2019Copper ContributorHi Matt. Is there anyway you could share this Flow?
As I understand it, you have designed a Flow that can send an email, when a news post have been published 🙂 Would really like to use that.
- Fredrik110Sep 21, 2020Copper Contributor
Hi Matt Weston,
I have done the setup for sending mail when a news post is published. Most of the time the Flow works great but sometimes it doesn't trigger, especially if users change pictures when creting the news post.
It is not even shown as failed in flow. I use "when a file is created(proprties only)" since the client doesnt want notifications for updates. Can it be that the promoted state =2 happen to be changed to something else for some reason when publishing? Have you got some ideas on what can be wrong or troubleshooting steps?
Best regards
/Fredrik
- Newbie270Jul 06, 2021Copper Contributor
This works 100% however..... If for some reason i go back to an older news post and edit or republish then another email comes out. Is there a way to send out the email on promote state = 2 (original news post) But not to send out any future emails even if someone makes a change to the post?
- gfhgf870Mar 28, 2022Copper Contributor
I'm probably too late to help anyone involved in the thread, however, for future users wondering how to solve this issue, here's how I did it.
There is a metadata field known as version number.This number increments it's decimal component every time a draft is saved, the first draft will be saved as version 0.1, the next time you open the news page's draft, the auto-saves for that "session" will be saved as a version 0.2. The decimal will only go up once you save a "new" draft.
Once you publish the news article, said version number changes to 1.0, if you were to edit the published article, those changes would be saved as version 1.1 (1.2 if you save it as a draft and keep editing it later on).
If you then decide to republish the news article, its version number will update to 2.0.
As far as i've seen, the pattern keeps going on
Now back to the original question, to avoid resending emails for updated news articles we can simply add a second line to our condition that checks if the version number is exactly 1.0. This way our conditional block checks if the modified file is a published news page (thanks to the promoted state == 2 condition) AND if it's the first version being published (version == 1.0).
NOTE: The "decimal" portion of the version number doesn't act like a decimal; in practice it works more like a second index annexed by a dot.
The sequence of version numbers would go such as:
0.1 < 0.2 < 0.3 < ... < 0.11 < 0.12 < ... < 0.21 < 1.0 < 1.1 ...
I hope this helps any future lurkers. - DNaughtonJan 10, 2022Copper Contributor
Hi Matt, this is really good. I have only one issue, I have set the Promoted State to 2, but when I publish the expression result is always false. If I set it to one, then it sends an email (draft or published). I have copied your flow exactly, any ideas?
Edit: I have just checked the raw outputs and it is saying the state is 1.