cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

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
Highlighted
Community Support
Community Support

Re: Mail subject filter

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

15 REPLIES 15
Highlighted
Community Support
Community Support

Re: Mail subject filter

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

Highlighted
Advocate II
Advocate II

Re: Mail subject filter

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

 

Highlighted
Regular Visitor

Re: Mail subject filter

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.

Highlighted
Advocate I
Advocate I

Re: Mail subject filter

I have the same question. Any answers?

Highlighted
Advocate I
Advocate I

Re: Mail subject filter

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/

Highlighted
Anonymous
Not applicable

Re: Mail subject filter

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.

Highlighted
Regular Visitor

Re: Mail subject filter

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

Highlighted
New Member

Re: Mail subject filter

Thanks, that works perfectly!

Highlighted
Advocate I
Advocate I

Re: Mail subject filter

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...

Highlighted
Regular Visitor

Re: Mail subject 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.

Highlighted
Advocate II
Advocate II

Re: Mail subject filter

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

Highlighted
Regular Visitor

Re: Mail subject filter

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

Highlighted
Regular Visitor

Re: Mail subject filter - Regular Expression Match [RegEx]

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

Highlighted
Regular Visitor

Re: Mail subject filter

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...

Highlighted
Helper I
Helper I

Re: Mail subject filter

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.

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Users online (7,173)