Skip to content

Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Problems
  • Triggers
  • Application specific solutions
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
Menu

Search for multiple words in the incoming email subject (Power Automate)

Posted on October 24, 2021October 24, 2021 by Tom

“How can I specify multiple words in the email subject in the ‘When a new email arrives’ Power Automate trigger, not just a single string?”


The trigger ‘When a new email arrives’ has a field called ‘Subject Filter’. In that field you can define a string that must be part of the email subject for the flow to trigger. If it’s not in the subject, the flow won’t run. But it’s just a single field expecting the whole string: all the words, in the specified order. If there’re 3 words, the subject must contain all 3 words, with the same separator, in the same order. Having as little as an extra space between the words won’t trigger the flow. Similar to that, it’s not possible to use the field for an OR condition trigger (wordA or wordB).

This post is about adding such possibilities in the ‘When a new email arrives’ trigger.

Use trigger conditions to check the subject

The ‘Subject Filter’ works as a trigger condition in the flow. It’ll check if the subject contains the string, and if it does, it’ll trigger the flow. The only difference is that this one is available directly on the trigger form.

Rewritten to standard trigger condition it would look as below. It’s just one extra row with the AND relationship to the other trigger conditions.

@contains(triggerOutputs()?['body/subject'], 'The whole string')

Knowing this, you can reproduce and extend the ‘Subject Filter’ as needed.

Search for all words, ignore order or separators

It doesn’t have to be just a single condition looking for the whole string. You can search for each of the words separately. The subject must have all of them, but their position doesn’t matter.

@contains(triggerOutputs()?['body/subject'], 'The')
@contains(triggerOutputs()?['body/subject'], 'whole')
@contains(triggerOutputs()?['body/subject'], 'string')
Power Automate multiple words email

Search for one of the words

You can also search for each word separately. Even if the email subject contains only one of the words, trigger the flow.

@or(
  contains(triggerOutputs()?['body/subject'], 'The'),
  contains(triggerOutputs()?['body/subject'], 'whole'),
  contains(triggerOutputs()?['body/subject'], 'string')
)
Power Automate multiple words email

You can even combine the conditions together with the AND (a separate row) and OR (all on one row) operators.

Summary

If you use the ‘When a new email arrives’ trigger in Power Automate, you’re not limited to the ‘Subject Filter’ when searching for multiple words. It’s just a predefined trigger condition moved to the trigger form. And since it’s a trigger condition, you can ignore it, and build your own trigger conditions. The final combination of AND and OR conditions to trigger the flow is up to you.

The same approach can be used also to ignore emails with a specific subject. For example, to skip all replies or forwarded emails check that the subject does not contain RE: or FW:.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

6 thoughts on “Search for multiple words in the incoming email subject (Power Automate)”

  1. Jen louis TERRANOVA says:
    January 26, 2022 at 2:26 pm

    Hello, Is there a way to trigger the flow only if the name of attached file starts with specifics letters ?

    Reply
    1. Tom says:
      January 29, 2022 at 7:11 pm

      Hello Jen,
      you can do that if the email contains only a single attachment:
      @startsWith(triggerOutputs()?['body']?['attachments'][0]?['name'],'string')
      I don’t think it’s doable for emails with multiple attachments.

      Reply
  2. mm says:
    February 2, 2022 at 2:45 pm

    How about extracting unknown length of texts from the newly arrived emails and directly save into a SP list? and those Texts in the emails could be aligned to left, OR center-aligned in the middle (within certain background picture). I saw some old forum posts saying need hard code. Example:
    Time: 02/02/2022
    Address: this can be short or very long
    Name: this can be short or long

    Reply
  3. Lucas says:
    May 12, 2022 at 8:54 am

    Thank you, thats a great hint.

    Reply
  4. Jarrot says:
    June 10, 2022 at 10:04 pm

    The same approach can be used also to ignore emails with a specific subject. For example, to skip all replies or forwarded emails check that the subject does not contain RE: or FW:.

    How would this look?

    Reply
    1. Tom says:
      June 19, 2022 at 9:39 am

      Hello Jarrot,
      just enclose the condition in not(…) to reverse it, e.g. @not(contains(triggerOutputs()?[‘body/subject’], ‘RE:’))

      Reply

Leave a Reply Cancel reply

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

Now available:

The Ultimate Power Automate expressions cheat sheet
Equip yourself with the tool to translate your thoughts into Power Automate expressions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Format results of date calculation in SharePoint columnJune 29, 2022
  • Why is your Power Automate flow creating duplicatesJune 26, 2022
  • How to create a unique identifier in your Power Automate flowJune 22, 2022
  • How to assign custom SharePoint permission level with Power AutomateJune 19, 2022
  • Remove permissions from a specific SharePoint user with Power AutomateJune 15, 2022

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

© 2022 Let's POWER Automate | Powered by Superbs Personal Blog theme