September 25, 2021

Sorting email manually is where productivity goes to die. But, even if you have a quick way to do it, nothing beats automatic, so Power Automate provides a trigger that helps you deal with emails as soon as they arrive. Today let’s explore the “When a new email arrives” trigger for Office 365.

Before we start, I’m doing the “V3” action, but I’ll change it in the future in case Microsoft releases a new one.

Where to find it?

You can find it by searching for “When a new email arrives.”

Alert:
Microsoft changed the way that Power Automate displays the steps. Now you have a huge list of actions that you can search. It’s arguable that this is simpler or not, but now I’ll only provide the search string you have to write to find the action.

It’s essential to define what is an email “arriving.” It doesn’t need to be an incoming email or an email that drops in the inbox. Instead, we consider “arriving” any email that is moved to a folder, when it arrives at your inbox, or you move it to another folder. This is super important because it opens the doors to automation based on moving emails to folders.

There are two versions of this trigger—one for Office 365 and another for Outlook.com. Please be sure to use “Office 365,” although the other one works in a very similar way.

Usage

There are a lot of fields that we can configure. Let’s look at them individually.

Folder

We don’t need to look at the inbox exclusively. We can have another folder that we look for new emails arriving. For example, you may have a folder where you send a pre-defined answer to the person that emails you. It’s a simple example, but you mustn’t limit yourself to email incoming emails.

If you want to look at shared mailboxes, you need to use the “When a new email arrives in a shared mailbox” trigger.

“To”, “CC”, “To or CC”, or “From”

These fields were a great idea from Microsoft when creating this trigger. Since we receive many emails, it doesn’t make sense for the trigger to fire each time we receive an email since we’re only looking for a sub-set. With these filters, we don’t need to add huge “Condition” or “Switch” actions to filter the emails you want. Instead, the trigger does all the work for you.

Please note that the trigger will run only if at least one matches, which is also good if you have strong limitations of the number of Flows you can run a day.

To use it, separate the emails with “;” You can have both internal and external emails, but keep this field with only the email. When you copy emails from some email clients, you’ll have the name associated with it, so be sure to remove it.

Finally, I want to highlight the “To or CC” field. If you add an email to the “To” field or the “CC” field, the email must contain both for the Flow to trigger. But if you want either one, you can use the “To or CC” field.

Importance

The “importance” field is often ignored, but some organizations can have strict rules on using it. If yours is one of them, you can have a Flow that sends you a notification each time a “High” priority email arrives, for example. The available possibilities are:

  1. Any
  2. High
  3. Normal
  4. Low

Only with Attachments

If you have a Flow that archives your attachments automatically, for example, you may want to trigger Flows that have them. Having your Flow trigger only when a condition is satisfied makes your life easier because you don’t need to validate, for each email that arrives, if there’s an attachment or not.

Include Attachments

Should the trigger include the attachment information or not? There is, however, something that you should know. Even if you enable this feature Flow (at the time of writing this article), it won’t fetch the attachments correctly. I go into detail in this article, but you need to know that you need to fetch the articles separately using the “Get email” action.

Subject Filter

Like the other fields, we can filter the subject for a specific string, and the Flow will only trigger if that condition is met.

Outputs

The trigger returns a lot of information in a JSON format, although the conversion from JSON is done automatically for you. Here’s an example:

{
    "headers": {
        "Pragma": "no-cache",
        "Transfer-Encoding": "chunked",
        "Retry-After": "3600",
        "x-ms-request-id": "<redacted>",
        "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
        "X-Content-Type-Options": "nosniff",
        "X-Frame-Options": "DENY",
        "Cache-Control": "no-store, no-cache",
        "Location": "<redacted>",
        "Set-Cookie": "<redacted>",
        "Timing-Allow-Origin": "*",
        "x-ms-apihub-cached-response": "true",
        "Date": "Wed, 01 Sep 2021 10:13:48 GMT",
        "Content-Type": "application/json; charset=utf-8",
        "Expires": "-1",
        "Content-Length": "25535"
    },
    "body": {
        "id": "<redacted>",
        "receivedDateTime": "2021-09-01T10:13:32+00:00",
        "hasAttachments": false,
        "internetMessageId": "<redacted>",
        "subject": "<redacted>",
        "bodyPreview": "<redacted>",
        "importance": "normal",
        "conversationId": "<redacted>",
        "isRead": false,
        "isHtml": true,
        "body": "<body's HTML>",
        "from": "<redacted>",
        "toRecipients": "manuel@manueltgomes.com",
        "attachments": []
    }
}

Limitations

You can’t access emails in shared libraries. to do that you need to use the “When a new email arrives in a shared mailbox” trigger.

Recommendations

Here are some things to keep in mind.

Use the filters wisely.

Using the filter fields is an amazing way to have your Flow trigger when the condition is met. But it’s important to know that only if all filters are met the Flow will trigger. So test your triggers and be sure that they are firing when you want them. Any email that should be parsed but doesn’t fit the filters will be ignored, so it’s a hidden error since there’s no error message or warnings.

Name it correctly

The name is super important in this case since there are a lot of filters. Define in the name what you’re trying to achieve. Always build the name so that other people can understand what you are using without opening the action and checking the details.

Always add a comment.

Adding a comment will also help to avoid mistakes. For example, indicate what emails you want to fetch and the ones to ignore, the exceptions, and what’s the reasoning behind that. It’s important to enable faster debugging when something goes wrong. Besides, it’s good to understand the mindset and requirements when building the Flow in case someone else is debugging or improving it.

Am I missing something? Leave a comment or interact on Twitter. Let’s work together to make this reference as complete as we can

Back to the Power Automate Trigger Reference.

Photo by Signature Pro on Unsplash

Manuel Gomes

I'm a Project Manager with experience in large projects and companies. I've worked in the past for companies like Bayer, Sybase (now SAP) and I'm currently working for Pestana Hotel Group.

View all posts by Manuel Gomes →

2 thoughts on “Power Automate: Office 365 When a new email arrives Trigger

  1. Use this all the time. I find using inbox rules in outlook to process the emails to a folder/sub folder and then the flow just has to monitor that folder. Gives you more flexibility in those rules.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: