cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Michal
Kudo Collector
Kudo Collector

Mail subject filter

Hi,

I am using the When a new email arrives in a shared mailbox action and want to filter out emails with the specific keyword in the subject. 

Instead of using the condition I tried Subject filter field but whatever I put there the action will work for any email subject. 

If you found it working for you, please share how to use it.

If you found it not working - question to the MS Flow team - please remove it or make it work and document it with an example so we know how it works. 

 

/Mike

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yamao-msft
Community Support
Community Support

Hi Michal,

 

We can use Subject Filter to search for the presence of specific words in the subject of an email. Your flow then runs actions based on the results of your search.


In the Subject Filter box, enter the text that your flow uses to filter incoming emails.


This documentation about Trigger a flow based on email properties could be a reference for you, please check it at here:
https://flow.microsoft.com/en-us/documentation/email-triggers/

 

Best regards,
Mabel Mao

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

20 REPLIES 20
v-yamao-msft
Community Support
Community Support

Hi Michal,

 

We can use Subject Filter to search for the presence of specific words in the subject of an email. Your flow then runs actions based on the results of your search.


In the Subject Filter box, enter the text that your flow uses to filter incoming emails.


This documentation about Trigger a flow based on email properties could be a reference for you, please check it at here:
https://flow.microsoft.com/en-us/documentation/email-triggers/

 

Best regards,
Mabel Mao

 

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you. It works now. I don't know why it was not working before. 

 

How do you specify multiple values? Like if i want to run the next step if the subject contains value1 OR Value2 OR Value 3, but NOT value 4.

I have the same question. Any answers?

You can use condition, for example, add a condition like

@or(contains(triggerBody()?['Subject'], 'A'),contains(triggerBody()?['Subject'], 'B'),contains(triggerBody()?['Subject'], 'C'))

 

Please refer to this link, it answers your question, mine too

https://marckean.com/2017/03/07/microsoft-flow-logic-app-conditions/

Anonymous
Not applicable

Subject filter is not acception whitespace. Eg- "Re: This is a new message." . I want to add this whole string in Subject Filter. But it is not working.

Anonymous
Not applicable

Hey daska - try using the string() expression, e.g. string('Re: This is a new message.')

Thanks, that works perfectly!

Is it possible to put a regular expression in the mail filter?

If it's not, this is really an oversight... for example I want to get only those emails that contain an ID Code in a specific format. How would I go about that?

Say i would want to find all mails with  following 999-XXX-999... (examples 123-ABC-789, 546-DEF-547) as far as i know I have two options now:

* using javascript (requiring an integration account)

* creating a azure function

 

Seems to me this is a waste of time and making logic apps more complex then they need to be.

Really hoping someone tells me i can just enter a regular expression in the filter...

I have the same problem, which I am struggling to solve.

 

Our customers use a Reference number in this format:

 

HR123456-10 (HR&6 digit number&-&2 digit number below 100)

Some earlier customers have a 5 digit number. And most customers only have a version number after the dash that goes to under 10. Some customers go more than 10 versions but these are very few.

You can use available solutions from Plumsail or build an Azure function yourself.

Thanks, will have a look and post my solution if I can do it.

Hi Michal @Michal ,

 

I have managed to get Regular Expression Match to work in my Power Automate Flow. I registered with Plumsail and created an API key (Key Type: Actions - Basic). You have to use PlumsailSP Connector not the Documents Connector via Plumsail when selecting in the Flow when editing it. 

 

My department uses a customer number in this format:

HR12345-1 or HR12345-12

or

HR123456-1 or HR123456-12

 

Basically the main number started at about 75000, but now most customers have a 6 digit number. Also customers have a version number normally under 10, but some times go past 9, so there are some with 2 digits after the dash.

 

So the "Pattern" is: 

^(HR\d{5,6}?-\d{1,2}?)

And for the Text Field I entered "Subject" in the Outlook 365 Connector (not sure what you call each element).

 

Basically the "^" means the RegEx starts at the start of the Field

 

In my following Condition I used "Match0" For the Yes side of the Condition to move the E-mail to a folder to be processed. Just a bit baffled because the No side does not seem to work for incorrect HR numbers (not entered), I need to address this. As I want to send a bounce back reply requesting the customer input the account number at the start of the Subject when resending. Before the email is deleted from the inbox.

 

Basically we struggle with so many emails from customers internal colleagues and third sector organisations, and no one is forced to put the customer number at the start of the subject. This would be very simple for us to sort the subjects in number order and see all the emails for each customer before processing.

 

I intend to further develop this with a RegEx in the main body of the emails as well. Basically the UK National Insurance Number is a critical bit of ID: AB123456C I think the RegEx pattern is: ([A-Z][A-Z]\d{6}[A-Z])

Also date of birth (in the UK) is useful dd/mm/yyyy I think the RegEx pattern is: (\d{2}/\d{2}/\d{4})

We could make it more prescriptive for the bounce back of incorrectly submitted emails. 

 

this is very helpful:

regexhero.net/library/

regexhero.net/reference/

 

Plumsail respond in under 24 hours so very helpful. 

 

Cheers James

PlumsailSP Connector - you will need to create an account on the Plumsail website and create a API Type: Actions – Basic.

 

You enter the API Key in the section of your Flow when inserting a PlumsailSP Connector, and then input the pattern which I think for you is:

(\d{3}-[A-Z][A-Z][A-Z]-\d{3})

 

And you enter where in the emails you want to find the Regular Expression.

 

It was suggested to me that I could try an Azure Function but I have looked into it and have no clue how to do this...

Anonymous
Not applicable

Hi @Gaolai ,

 

I tried using this but it didn't work, my trigger is email with specific words as subject filter, i want to look for pricing or cost in the subject line. I tried 

@or(contains(triggerBody()?['Subject'], 'Price'),contains(triggerBody()?['Subject'], 'Pricing'),contains(triggerBody()?['Subject'], 'Cost')) 

 

into the subject filter, but it didnt give results. Am i missing out on something?

 

Thanks.

Finally got the RegEx to work yesterday. Basically picked the wrong Plumsail SP element in the Flow. So after a new email arrives I now have RegEx Test (Plumsail SP) and the RegEx is:

^(HR\d{5,6}-\d{1,2})

I want to send an Email to Applicants requesting they resend the Email with the Application number at the start of the Subject Field. And then delete the Email.

 

Applicants who correctly have the application number at the start of the Subject get a confirmation Email for receipt and then the email is moved to a folder for processing.

 

The definite actions can be problematic when testing on your personal Outlook Inbox. I decided to have a spreadsheet in One Drive for RegExYes and separately for RegExNo, to prove the Flow is working, before implementing on a Shared Email. The Spreadsheets on the Shared Inbox will be a good way to test before doing the non passive actions that are not reversible. Body Preview in the Spreadsheet Rows is difficult particularly if the Email is long so, I may remove this, not sure if you can force Row height in the Excel Spreadsheets.

 

I have worked out more RegEx for possible Applicant verification as well as the Application Number:

Postcode outside London:

[A-Z]\d{1,2}\s+\d{1}[A-Z][A-Z]

 

Date of Birth UK:

\d{2}/\d{2}/\d{4}

 

National Insurance Number UK:

[A-Z][A-Z]\d{6}[A-Z]

 

I have Conditions before the RegEx Test to take staff emails away from the Reg Ex by saying "From" "ends with" "Email domain after @"

RegEx Test (Plumsail SP) at start of E-mail SubjectRegEx Test (Plumsail SP) at start of E-mail Subject

Michal
Kudo Collector
Kudo Collector

Inspired by @Gaolai I have tried out complex conditions. It took me a while to understand the syntax.
I have explained how to build complex trigger conditions in my article "Trigger conditions - filling the information gap". I hope some find it useful.

link broken

Balajis15
Regular Visitor

Hello, I have a question with regards to subject filter. May i know if the notifications can be triggered only once even if the same mail is forwarded back and forth. As of now i keep getting notifications multiple times for the same email.

Helpful resources

Announcements

Power Platform Connections - Episode 7 | March 30, 2023

Episode Seven of Power Platform Connections sees David Warner and Hugo Bernier talk to Microsoft MVP Dian Taylor, alongside the latest news, product reviews, and community blogs.     Use the hashtag #PowerPlatformConnects on social media for a chance to have your work featured on the show!      Show schedule in this episode:    0:00 Cold Open 00:30 Show Intro 01:02 Dian Taylor Interview 18:03 Blogs & Articles 26:55 Outro & Bloopers    Check out the blogs and articles featured in this week’s episode:    https://francomusso.com/create-a-drag-and-drop-experience-to-upload-case-attachments @crmbizcoach https://www.youtube.com/watch?v=G3522H834Ro​/  @pranavkhuranauk https://github.com/pnp/powerapps-designtoolkit/tree/main/materialdesign%20components @MMe2K​ https://2die4it.com/2023/03/27/populate-a-dynamic-microsoft-word-template-in-power-automate-flow/ @StefanS365 https://d365goddess.com/viva-sales-administrator-settings/ @D365Goddess https://marketplace.visualstudio.com/items?itemName=megel.mme2k-powerapps-helper#Visualize_Dataverse_Environments @MMe2K    Action requested:  Feel free to provide feedback on how we can make our community more inclusive and diverse.    This episode premiered live on our YouTube at 12pm PST on Thursday 30th March 2023.    Video series available at Power Platform Community YouTube channel.    Upcoming events:  Business Applications Launch – April 4th – Free and Virtual! M365 Conference - May 1-5th - Las Vegas Power Apps Developers Summit – May 19-20th - London European Power Platform conference – Jun. 20-22nd - Dublin Microsoft Power Platform Conference – Oct. 3-5th - Las Vegas    Join our Communities:  Power Apps Community Power Automate Community Power Virtual Agents Community Power Pages Community    If you’d like to hear from a specific community member in an upcoming recording and/or have specific questions for the Power Platform Connections team, please let us know. We will do our best to address all your requests or questions.       

Announcing | Super Users - 2023 Season 1

Super Users – 2023 Season 1    We are excited to kick off the Power Users Super User Program for 2023 - Season 1.  The Power Platform Super Users have done an amazing job in keeping the Power Platform communities helpful, accurate and responsive. We would like to send these amazing folks a big THANK YOU for their efforts.      Super User Season 1 | Contributions July 1, 2022 – December 31, 2022  Super User Season 2 | Contributions January 1, 2023 – June 30, 2023    Curious what a Super User is? Super Users are especially active community members who are eager to help others with their community questions. There are 2 Super User seasons in a year, and we monitor the community for new potential Super Users at the end of each season. Super Users are recognized in the community with both a rank name and icon next to their username, and a seasonal badge on their profile.  Power Apps  Power Automate  Power Virtual Agents  Power Pages  Pstork1*  Pstork1*  Pstork1*  OliverRodrigues  BCBuizer  Expiscornovus*  Expiscornovus*  ragavanrajan  AhmedSalih  grantjenkins  renatoromao    Mira_Ghaly*  Mira_Ghaly*      Sundeep_Malik*  Sundeep_Malik*      SudeepGhatakNZ*  SudeepGhatakNZ*      StretchFredrik*  StretchFredrik*      365-Assist*  365-Assist*      cha_cha  ekarim2020      timl  Hardesh15      iAm_ManCat  annajhaveri      SebS  Rhiassuring      LaurensM  abm      TheRobRush  Ankesh_49      WiZey  lbendlin      Nogueira1306  Kaif_Siddique      victorcp  RobElliott      dpoggemann  srduval      SBax  CFernandes      Roverandom  schwibach      Akser  CraigStewart      PowerRanger  MichaelAnnis      subsguts  David_MA      EricRegnier  edgonzales      zmansuri  GeorgiosG      ChrisPiasecki  ryule      AmDev  fchopo      phipps0218  tom_riha      theapurva  takolota     Akash17  momlo     BCLS776  Shuvam-rpa     rampprakash  ScottShearer     Rusk  ChristianAbata     cchannon  Koen5     a33ik  Heartholme     AaronKnox  okeks      Matren   David_MA     Alex_10        Jeff_Thorpe        poweractivate        Ramole        DianaBirkelbach        DavidZoon        AJ_Z        PriyankaGeethik        BrianS        StalinPonnusamy        HamidBee        CNT        Anonymous_Hippo        Anchov        KeithAtherton        alaabitar        Tolu_Victor        KRider        sperry1625        IPC_ahaas      zuurg    rubin_boer   cwebb365   Dorrinda   G1124   Gabibalaban   Manan-Malhotra   jcfDaniel   WarrenBelz   Waegemma   drrickryp   GuidoPreite    If an * is at the end of a user's name this means they are a Multi Super User, in more than one community. Please note this is not the final list, as we are pending a few acceptances.  Once they are received the list will be updated. 

Register now for the Business Applications Launch Event | Tuesday, April 4, 2023

Join us for an in-depth look into the latest updates across Microsoft Dynamics 365 and Microsoft Power Platform that are helping businesses overcome their biggest challenges today.   Find out about new features, capabilities, and best practices for connecting data to deliver exceptional customer experiences, collaborating, and creating using AI-powered capabilities, driving productivity with automation—and building towards future growth with today’s leading technology.   Microsoft leaders and experts will guide you through the full 2023 release wave 1 and how these advancements will help you: Expand visibility, reduce time, and enhance creativity in your departments and teams with unified, AI-powered capabilities.Empower your employees to focus on revenue-generating tasks while automating repetitive tasks.Connect people, data, and processes across your organization with modern collaboration tools.Innovate without limits using the latest in low-code development, including new GPT-powered capabilities.    Click Here to Register Today!    

Check out the new Power Platform Communities Front Door Experience!

We are excited to share the ‘Power Platform Communities Front Door’ experience with you!   Front Door brings together content from all the Power Platform communities into a single place for our community members, customers and low-code, no-code enthusiasts to learn, share and engage with peers, advocates, community program managers and our product team members. There are a host of features and new capabilities now available on Power Platform Communities Front Door to make content more discoverable for all power product community users which includes ForumsUser GroupsEventsCommunity highlightsCommunity by numbersLinks to all communities Users can see top discussions from across all the Power Platform communities and easily navigate to the latest or trending posts for further interaction. Additionally, they can filter to individual products as well.   Users can filter and browse the user group events from all power platform products with feature parity to existing community user group experience and added filtering capabilities.     Users can now explore user groups on the Power Platform Front Door landing page with capability to view all products in Power Platform.      Explore Power Platform Communities Front Door today. Visit Power Platform Community Front door to easily navigate to the different product communities, view a roll up of user groups, events and forums.

Microsoft Power Platform Conference | Registration Open | Oct. 3-5 2023

We are so excited to see you for the Microsoft Power Platform Conference in Las Vegas October 3-5 2023! But first, let's take a look back at some fun moments and the best community in tech from MPPC 2022 in Orlando, Florida.   Featuring guest speakers such as Charles Lamanna, Heather Cook, Julie Strauss, Nirav Shah, Ryan Cunningham, Sangya Singh, Stephen Siciliano, Hugo Bernier and many more.   Register today: https://www.powerplatformconf.com/   

Users online (1,592)