Power Automate to monitor a shared mailbox

Office 365 Outlook and Microsoft Teams
Microsoft Office 365 Outlook and Microsoft Teams connector

In this post, I am going to show you how I monitor a shared mailbox while working from home.

Why did I need this?

If I am going to be honest, there are a couple of reasons why I need this.

  1. I have not made a post in a while
  2. It is a great introduction into Power Automate and Teams
  3. There have been a couple of e-mails to my shared mailbox that have sat longer than I would have liked because I did not know they were there

The Goal

My objective is simple. When a new e-mail message arrives in my shared mailbox then notify me in Microsoft Teams.

You: Why don’t you just do …

See #2 above. I actually thought is this really necessary before I started down this path. To my surprise, it actually is not really a bad idea. Take a look at some of the other options to accomplish shared mailbox notifications at https://www.msoutlook.info/question/new-mail-alert-for-delegate-or-shared-mailboxes.

Power Automate

Microsoft Power Automate is a part of the Power Platform.

Take care of what’s important. Automate the rest.

Create automated workflows with Microsoft Power Automate.

Microsoft

I access Power Automate by navigating to https://www.office.com/.

Office 365 home screen
O365 landing page

For our purposes we will be using Automated flow. Review the other connector triggers at https://docs.microsoft.com/en-us/connectors/office365/#triggers.

Ways to make a flow
Automated flow, Instant flow, Scheduled flow, or Business process flow

Has anyone noticed that ‘Flow’ is referenced everywhere? Power Automate used to be called Flow.

Give your flow a name and choose a trigger. For our purposes we will be using When a new email arrives in a shared mailbox (V2).

Choose your flow's trigger
Name your flow and choose your flow’s trigger

Trigger Step

Begin creating your flow by adding details to the trigger event.

Trigger details
Collapsed Trigger Details
Trigger Details
Expanded Trigger Details

You will notice the only required field is the mailbox address. I entered the e-mail address of my shared mailbox and that is it.

+ New Step

At this point we need to identify what happens after the trigger. I have decided I want a notification in Teams however, it could have been something else. Microsoft Teams happens to be listed front and center for me.

Choose an action
Choose what action will occur next

Use the Search bar if your action category is not visible.

Available Teams actions
List of Microsoft Teams Actions

There are quite a few options to connect to Microsoft Teams. For our purposes, we will use Post a message as the Flow bot to a user.

Post a message as the Flow bot to a user
Post a message as the Flow bot to a user

Adding Dynamic Content

The real power in this is being able to use dynamic content from the previous steps. I will make a complaint however. The fly-out sometimes gets in the way or is not visible and it does get annoying.

Dynamic content fly-out
The Dynamic content and Expression fly-out

In general, the descriptions of the fields are easily understandable. Refer to the documentation at https://docs.microsoft.com/en-us/connectors/office365/ if needed.

Inserting the fields is pretty straightforward. Place the cursor and select the field.

Formatting the message output
It is pretty much “drag & drop”

Learn about formatting syntax at https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cconnector-html.

Using Expressions

I wanted to include this section because adding a click-able link within my notification just seemed to make sense to really finish out the project. Think about it. I am going to get a notification in Teams. I do not want to have to switch programs to Outlook then select the mailbox then select the e-mail.

Yes, it is true that I will have to open another program to actually view the e-mail but, I will not have to switch programs manually.

Leveraging [‘conversationId’]

If you look at the URL of an email message in O365 Outlook you’ll see something like:

https://outlook.office.com/mail/sharedbox@mail.com/inbox/id/randomLettersNumbersSymbols

Our trigger event returns many items, but what we are interested in is a string called ‘conversationId’.

It took me a little bit to realize that the returned string needed to be slightly modified in order to open the exact email. However, once I did, I used an expression to find these values and replace them with their URL values.

replace(replace(triggerBody()?['conversationId'],'-','%2F'),'=','%3D')

The Results

3 thoughts on “Power Automate to monitor a shared mailbox”

  1. This is great! Do you need to be a member of the shared mailbox? I’m getting an error “The specified object was not found in the store., The process failed to get the correct properties.”. I have users that wants me to create it for them but I’m not part of the shared mailbox.

    1. You can add yourself to the group however, I suggest you export and have the user import into their profile.

Leave a Reply

Your email address will not be published. Required fields are marked *

css.php