Flow: Send A Happy Birthday Email Message To Everyone In Your Organisation

Quite regularly I hear requests that centre around wishing users a Happy Birthday within an organisation. There is an extremely popular template within the Flow template gallery that does just that, it is called "Send a Happy Birthday email to employees on their birthday" and it uses a SharePoint list. It work's really well, although sometimes date formats can become an issue for the Flow implementer when they are imported from the list. Also, the organisation's users need to be added to the list itself in advance. Whilst that isn't a huge chore for most people, below is a process that requires no list and will send an email to every enabled user in your O365 tenant at 9am on the day of their birthday.

Sound, interesting?

Well, read on and follow the steps and you too will be able to implement this process.

Your email will look like this.

Pre-requisites: You will need a suitable Office 365 group. This may be an "All Users" group or a segmented group that only has users who have agreed to recieve such an email. Maybe it's a group that omits the CEO or those who may not celebrate their birthday. I will leave that to you to decide, but in this example a pre-configured "All Users" group is in use.

Here is the complete Flow.

Let's get started by creating a blank Flow and setting the trigger. The trigger in this case is a "Recurrence" which will be set to run at 9am daily with a start date that means when implemented, it will run like clockwork on the hour.

Note: The start date is in this format – 2019-03-20T09:00:00Z. If your in a non UTC timezone the "Z" at the end will not be required.

Here is the trigger.

We then use the "List group members" action from the "Office 365 Groups" connector. I have named it "List All Users" by click the elipses (…) in the top right.

As there are likely multiple users in your organisation then we will need to set an "Apply to each" to allow us to iterate through each one checking to see if it is the user's birthday or not. We will call it "Apply To Each User Account In All Users".

Time to use the "Office 365" connector and the action called "Get user profile (V2)".

The next step covers the all important condition. It checks if it is the user's birthday and it makes sure the group member is set to "enabled". No need to be wishing those disabled accounts (leavers or shares) a Happy Birthday.

1.

formatDateTime(body('Get_user_profile_(V2)')?['birthday'], 'MM-dd')

is equal to

formatDateTime(utcNow(), 'MM-dd')

2.

body('Get_uer_profile_(V2)')?['accountEnabled']

is equal to

true

3.

body('Get_uer_profile_(V2)')?[birthday']

is not equal to

0001-01-01T00:00:00Z

There is no need for the No branch in this Flow as it will run successfully with no output if no-one has a birthday on that day.

For the Yes branch.

We add the user to an image or gif. You can get to the url of the image here: http://bit.ly/2TWrfQe

We now use the above web based url in the email body with the "Send an email" action. This means if you want to change the image you can.

So there we have it, you now have a neat Happy Birthday process that targets any group in Office 365.

Thanks, Alan