Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Triggers
  • Resources
  • ABOUT ME
  • Get help with your flow
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.

11 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
  5. DJ says:
    August 18, 2022 at 10:03 am

    great help. thanks.

    Reply
  6. Emmanuel says:
    August 22, 2022 at 3:22 pm

    Hello. That is exactly what I want to do. I just need a precision. Do you insert directly the text of the trigger conditions in the Subect Filter text area ? When I test like that, I have an error : One or more fields provided is of type ‘Null’, a different type is expected.
    My trigger conditions : @or(contains(triggerOutputs()?[‘body/subject’], ‘Info Production ‘), contains(triggerOutputs()?[‘body/subject’], ‘Info SNP – Production/Other’))
    Thanks for your help.

    Reply
    1. Emmanuel says:
      August 22, 2022 at 6:03 pm

      Sorry for previous question. The form to setup trigger condition(s) is accessible in ‘parameters’ (…) of ‘When a new email arrives V3’ Form.
      Thanks a lot.

      Reply
  7. David says:
    April 12, 2023 at 9:06 pm

    We are attempting to do this trigger with when an email an email arrives from a shared mailbox V2. There is no V3 for shared mailbox. We are not able to get this trigger to work. Any help is appreciated.

    @or( contains(triggerOutputs()?[‘body/subject’], ‘Essay’),
    contains(triggerOutputs()?[‘body/subject’], ‘MDMP’),
    contains(triggerOutputs()?[‘body/subject’], ‘application’),
    contains(triggerOutputs()?[‘body/subject’], ‘submission’)
    )

    Reply
    1. Tom says:
      May 1, 2023 at 3:31 pm

      Hello David,
      the trigger condition looks fine to me, I’d check if it’s not blocked by something else set in the trigger action directly.

      Reply

Leave a Reply Cancel reply

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

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


There's also the HTTP requests to SharePoint cheat sheet to help you overcome limitations of some standard actions!

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.

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with 1000s of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes