Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Outlook
    • Planner
    • Power Apps
    • SharePoint
    • Teams
  • Triggers
  • Ready to use solutions
    • Approval Process Template
    • Task Delegation App
    • The Ultimate Power Automate expressions cheat sheet
    • Power Automate HTTP requests to SharePoint cheat sheet
    • Power Automate HTTP requests to Graph API cheat sheet
  • ABOUT ME
  • Get help with your flow
  • POWER PLATFORM SERVICES
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:.


πŸš€ Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

14 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
  8. Luke says:
    August 9, 2023 at 2:27 am

    Brilliant tip. Thank you for that. Very handy indeed

    Reply
  9. alex says:
    March 7, 2024 at 10:14 pm

    Question, in the adaptive card. Is there a way to show the body of the email? Not only the body/subject…. is there a way to show like the first few line of the email or the entire email?

    Reply
  10. Analyst says:
    July 3, 2024 at 12:58 pm

    When a new email arrives (V3) is my first step in the flow

    Used the trigger condition as contains(triggerOutputs()?[‘body/subject’], ‘The’),
    Got the error below while saving
    Request to Azure Resource Manager failed with error: ‘{“error”:{“code”:”InvalidTemplate”,”message”:”The template language expression evaluation failed: ‘The template language function ‘contains’ expects its first argument ‘collection’ to be a dictionary (object), an array or a string. The provided value is of type ‘Null’.’.”}}’.

    So changed the condition to
    contains(triggerOutputs()?[‘body/value’], ‘The’),

    The flow got saved without error but does not work on triggering keeps running without any action
    When clicked on test button test after selecting historical run nothing happens

    Reply

Leave a Reply Cancel reply

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

πŸš€ Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

Working on an Approval process?

Use the Approval Process Template and the Task Delegation App to skip the hard part and deploy a fully functional approval solution on a SharePoint list in minutes! And then the next one, and the next one...

Approval Template Preview ✨ Learn more ✨

Turn ideas into flows with ease!

Grab the complete Power Automate Cheat Sheet Bundleβ€”everything you need to master expressions, SharePoint HTTP calls, and Graph API in Power Automate.

Cheat Sheet Bundle Preview ✨ Get the Cheat Sheets

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 thousands of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2025 Let's POWER Automate | Theme by SuperbThemes