When a New Email Arrives Subject Filter in Power Automate [3 Methods]

Do you need to limit your flows triggered when a new email arrives based on the subject line?

Suppose you have a flow set up based on the When a new email arrives trigger. This is going to run for every email that arrives in your inbox or other chosen folder.

But you might only want this automation to hap[en for specific emails based on the subject line. This can be achieved with the built-in subject filter input or by using specific trigger conditions found in the trigger settings menu.

This post is going to show you several different ways to get a subject line filter for your flows in Power Automate.

Subject Filter with Folders and Outlook Rules

You can actually avoid setting up the subject filter in Power Automate and use features in Outlook instead.

You can achieve the same result by setting up a folder and rules in Outlook to send emails based on the subject line to the folder.

Then in Power Automate, you can set the trigger to only run for emails that arrive in the folder. This way you can adjust the filter from Outlook by changing the rule.

Create a New Folder in Outlook

The first thing you will need to do is set up a folder for your Outlook rule.

This is the location you will automatically send emails based on the subject line.

  • Right-click on the Folders heading where your inbox and other Outlook folders are contained.
  • Select the Create new option from the menu.

You can also right-click on any existing folder and choose the Create new subfolder option and then set up the rules and Power Automate trigger based on the subfolder.

Create a New Rule in Outlook

Now you can set up the Outlook rule to automatically send new emails to the new folder when they meet certain conditions with the subject line.

Here’s how to set up a rule in Outlook.

  1. Click on the Setting icon at the top right.
  2. Click on the View all Outlook settings link at the bottom.

This will open the Outlook setting menu.

  1. Go to the Mail tab.
  2. Go to the Rules tab.
  3. Click on the Add new rule button to create a new rule.

This opens the menu where you can build out the logic for your rule.

  1. Give your rule a new name.
  2. Select the Subject includes option under the Add a condition section.
  3. Enter some text in the input. When an email arrives that contains this text, the rule will be triggered.
  4. Select the Move to option under the Add an action section.
  5. Select the new folder previously created.
  6. Press the Save button to enable the rule.

Now, whenever a new email arrives it will automatically bypass the inbox and be moved to the folder.

📝 Note: The rules are not case-sensitive and will trigger regardless if the text string is upper or lower case.

Outlook rules are an easy way to create complex conditions for your subject filter.

  • You can create an OR condition by entering more than one text in a condition. Press Enter to add separate text conditions.
  • You can create an AND condition by creating a new condition with the Add another condition link in the Add a condition section.

This is a much easier option than creating complex AND / OR conditions with Power Automate trigger conditions.

Set the Folder in the Trigger Action

Now that you have your folder and Outlook rules created, you can easily set up your Power Automate trigger.

  1. Create a flow using the When a new email arrives trigger.
  2. Select the folder you created in the Folder option.

That is all you need to do! You can leave the Subject Filter in the trigger empty since this is done in the Outlook rule.

When an email arrives with a subject that matches your rule, the flow will run.

Subject Filter with Advanced Options

This is the most common method, as it can all be set up easily from the trigger in Power Atuoamte.

The When a new email arrives trigger has an input called Subject Filter that allows you to add any text. This is then used to only trigger the flow when the email contains that specific text.

The condition will search the full subject line and if the text is contained anywhere within, then the flow will run. Otherwise, the flow does not run.

📝 Note: This Subject Filter is not case-sensitive. That means if you enter HELLO in the Subject Filter, the flow will still run when any email arrives with a subject that contains the word hello.

Here is how to create a subject filter with advanced options.

  1. Create a flow with the When a new email arrives trigger.
  2. Select the inbox or any other folder in the Folder option.
  3. Click on Show advanced options.

This will reveal more inputs including the subject filter.

  1. Enter the text that you want to test the subject line based on in the Subject Filter input.

When the subject line of any incoming email contains the text in the Subject Filter, the flow will be triggered. Otherwise, the flow does not run.

Subject Filter with Trigger Conditions

This is the most powerful and flexible way to create a subject filter for your flows.

You can create your own custom logic as well as extend this to filter based on the email body or other properties.

This method is more difficult as it does require writing your own logical formula with Power Automate workflow expression functions.

How to Add a Trigger Condition

Trigger conditions can be added from the trigger settings menu.

When you add a trigger condition the flow will only run when the expression evaluates to true.

Here’s how to add a trigger condition to your flow.

  1. Click on the Ellipses icon in the top right of the When a new email arrives trigger action.
  2. Select the Settings option from the menu.

This opens the Settings menu.

  1. Click on the Add button in the Trigger Conditions section. This will create an input where you can paste in your condition.
@contains(triggerOutputs()?['body/subject'],'<yourtext>')
  1. Add in your trigger condition expression. For example, the above expression will test if the email subject contains the string <yourtext>. If this expression evaluates to true, then the flow will run.
  2. Press the Done button to save the condition in your trigger.

📝 Note: Your trigger condition expression must start with the @ symbol. This tells Power Automate what comes after is an expression that it needs to evaluate.

When creating trigger conditions on the subject line, you will need to reference the dynamic content from the trigger for the subject line as triggerOutputs()?['body/subject'].

📝 Note: Your trigger conditions will be case-sensitive unless you specifically build an expression that ignores the case.

Subject Line Contains Text Trigger Condition

@contains(triggerOutputs()?['body/subject'],'<yourtext>')

The above expression will test if the subject line contains <yourtext>.

Subject Line Starts with Text Trigger Condition

@startsWith(triggerOutputs()?['body/subject'], '<searchText>')

The above formula will test if the subject starts with the text <searchText>.

Subject Line Ends with Text Trigger Condition

@endsWith(triggerOutputs()?['body/subject'], '<searchText>')

The above formula will test if the subject ends with the text <searchText>.

Subject Line Trigger Condition with AND Logic

@and(
	startsWith(triggerOutputs()?['body/subject'], '<searchText1>'),
	endsWith(triggerOutputs()?['body/subject'], '<searchText2>')
)

The above formula will test if the subject starts with the text <searchText1> and ends with the text <searchText2>.

Both conditions need to be true for the flow to run.

Subject Line Trigger Condition with OR Logic

@or(
	startsWith(triggerOutputs()?['body/subject'], '<searchText1>'),
	endsWith(triggerOutputs()?['body/subject'], '<searchText2>')
)

The above formula will test if the subject starts with the text <searchText1> or ends with the text <searchText2>.

Only one condition needs to be true for the flow to run.

Subject Line Case Insensitive Trigger Condition

Building a case-insensitive expression is easy. All you need to do is first convert the subject line to lowercase.

Then you can use the lowercase expression in your condition.

This can be done using the toLower function. This converts any text to all lowercase.

@contains(toLower(triggerOutputs()?['body/subject']),'<yourtext>')

For example, the above expression will test if the lowercase version of the subject line contains a given text.

Conclusions

Limiting your flow run based on the subject line in an email can be an essential part of the automation logic.

There is a built-in way to limit the flow based on the subject line using the Subject Filter input. This will limit the flow to run only when the subject contains the given text string.

You might want to include more specific logic for your filtering. This is possible either using Outlook rules or the trigger conditions in the settings menu.

What is your preferred method to implement the subject filter? Let me know in the comments below!

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Related Articles

Comments

1 Comment

  1. arbaz

    the flow keeps repeating again and again for some reason
    i have the subject line filter set as “awc”

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!