Skip to main content

Notifications

Power Automate - General Discussion
Unanswered

Filter email based on certain keywords

(0) ShareShare
ReportReport
Posted on by 6

Hi there, 

We are trying to find a way where we can filter emails based on certain keywords. 

Our team received a certain kind of email from a specific email address. In that email we want to search if certain keywords appear or not. If they do appear then we want to have close look at the email if not then we want the email to be deleted. 

We tried created a rule in Inbox of the Outlook where we created a condition stating that if the email comes from the specific address then the action is to move it to a new folder. 

Then in this new folder we created a rule that if "Message body includes" let's say the word "user" then the action is to move that email into inbox so that we can see it. 

This way we can contain all the email in the new folder from the specific email address and then move items from it to the inbox. 

However the problem we ran into is that Outlook doesn't gives an option to restrict filtering the email body to exact match of the keyword. For example- if we want soil treatment as a keyword then Outlook treat soil and treatment as separate keyword. 

During our test we found that if the email only contains treatment, it is still moved from the new folder to inbox. 

We only want email containing soil treatment to be moved from the new folder to inbox. 

 

After having no success with Outlook rules we tried to use Power Automate but we are not sure how to it setup. 

All we want is to filter an email from an specific email address based on certain keywords (we have over 100 of them) and if the email contains the keywords then keep them in inbox otherwise delete them, because we don't to read them as it is not relevant to us.

 

Not sure what is the best option. We could also try an app that works with Outlook, if it works.

 

Thanks 

 
  • AlexEncodian Profile Picture
    AlexEncodian 4,298 on at
    Re: Filter email based on certain keywords

    @Username18 

    You could use Encodian's Utility - Search Text (Regex) action to search for keywords and then use a length() condition to see if any keywords were returned.

     

    Given the number of keywords you have, the regex expression would be quite long though. 

    e.g. finding 3 strings using OR function

    (soil treatment|earth treatment|contaminated soil)
  • VictorIvanidze Profile Picture
    VictorIvanidze 11,853 on at
    Re: Filter email based on certain keywords

    It's time to learn! 😉

  • Username18 Profile Picture
    Username18 6 on at
    Re: Filter email based on certain keywords

    Thank you for your help. But I've no expertise in Power Automate so not sure what changes to make to make it work.

  • VictorIvanidze Profile Picture
    VictorIvanidze 11,853 on at
    Re: Filter email based on certain keywords

    Well, you can easily modify it.

  • Username18 Profile Picture
    Username18 6 on at
    Re: Filter email based on certain keywords

    Thanks 

    I couldn't try it. We are looking to sort email from a specific email address by keywords in the main body. 

    Any email that doesn't contain keywords that we are looking for should either be deleted or moved to inbox. 

     

  • Username18 Profile Picture
    Username18 6 on at
    Re: Filter email based on certain keywords

    Thanks

    I tried but it gives an error.

     

    Username18_0-1706711794156.png

    Wondering in the first box "When a new email arrives" can we change it to "From" instead of "Inbox". Asking becuase we want to filter email from a specific email address not all the email in the inbox. 

    Also, in the last box for yes, will the flow work if we change move email and point it to Inbox and if no the email is deleted.

    This way, any email that doesn't contains keywords (in the main body of the email) that we are looking for are either deleted or moved to inbox. 

    I tried both ways. The one you mentioned here and the with the changes that I'm asking for but none of them worked. 

    I'll also mention that it's possible that the emails might not contain any of the keywords we are looking for or might contain some. We have over 100 keywords that we want to search in every email that from this sender. 

    We also want the keywords to be a exact match otherwise it doesn't helps and is same as setting up rules in the Outlook.

    The error in the second box from top is

    "BadRequest

    The variable 'Email Bid' of type 'Array' cannot be initialized or updated with value of type 'String'. The variable 'Email Bid' only supports values of types 'Array'."
  • VictorIvanidze Profile Picture
    VictorIvanidze 11,853 on at
    Re: Filter email based on certain keywords

    Try to use this flow as a base: https://ivasoft.com/sortemailsflow.shtml

    and modify it according your needs.

  • zbegumdost Profile Picture
    zbegumdost 287 on at
    Re: Filter email based on certain keywords

    hi,

     

    Try this

     

    2.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,343

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard