web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Filter an email that i...
Power Automate
Answered

Filter an email that it doesn't contain "RE:" with Get emails (v3)

(2) ShareShare
ReportReport
Posted on by 24

Hi everyone,

I'm trying to analyze sent emails and need to filter out replies. Specifically, I want to retrieve only emails whose subject does not contain "RE:" using Get emails (V3).

I've tried several approaches (works only with KQL), but none of them seem to work:

1. -subject:'RE:' AND sent>=@{addDays(utcNow(), -30, 'yyyy-MM-dd')} AND sent<=@{addDays(utcNow(), -2, 'yyyy-MM-dd')} 
2. NOT subject:'RE:' AND sent>=@{addDays(utcNow(), -30, 'yyyy-MM-dd')} AND sent<=@{addDays(utcNow(), -2, 'yyyy-MM-dd')} 
3. (NOT subject:'RE:') AND sent>=@{addDays(utcNow(), -30, 'yyyy-MM-dd')} AND sent<=@{addDays(utcNow(), -2, 'yyyy-MM-dd')} 
4. subject<>'RE:' AND sent>=@{addDays(utcNow(), -30, 'yyyy-MM-dd')} AND sent<=@{addDays(utcNow(), -2, 'yyyy-MM-dd')} 

My goal is to exclude any emails that are replies and only get original messages within a specific date range.

Is there a correct way to achieve this kind of filtering?

Thanks in advance for your help!

ErrorFiltering.png
Categories:
I have the same question (0)
  • 11manish Profile Picture
    3,333 on at
    try below :
     
    @not(contains(toLower(item()?['subject']), 're:'))
     
  • Alemax Profile Picture
    24 on at
    Remember that the condition for Search Query uses KQL. Also, in this case, there is no value for item()?['subject'].

    Thanks for the help!
  • Suggested answer
    Haque Profile Picture
    3,653 on at
    Hi @Alema
     
    Here is the KQL:
    not(startswith(tolower(subject), "re:"))
    
     If we consider there is a chance subject would be null/empty.
    subject != "" and subject != null and not(contains(tolower(subject), "re:"))
     
     
    Bit of optimized one if you care aboutd null/empty and leading and trail white spaces (not in KQL).
    @and(
      not(empty(item()?['subject'])),
      not(startsWith(toLower(trim(item()?['subject'])), 're:'))
    )
    
     
    contains vs startsWith
     
    Thanks.
     
  • Alemax Profile Picture
    24 on at
    Hi @Haque, 

    With the first option, no results were returned, while the second one returned everything. 
     
    Thank you!
  • Suggested answer
    rezarizvii Profile Picture
    352 on at

    Hi @Alema, hope you are doing well.

    Try using this formula:
    NOT subject:Re AND sent>=@{addDays(utcNow(), -30, 'yyyy-MM-dd')} AND sent<=@{addDays(utcNow(), -2, 'yyyy-MM-dd')}



    Note: While this works and filters out emails that contain 'Re:', it also filters out emails where the subject contains any word that starts with 'Re' like 'Repeat' or 'Reorder'. I could NOT find a way to make it only consider 'Re:' as I kept getting a bad request error which said ':' is not a valid character. Using NOT subject:(Re: ) allowed the colon, but it ignored it in the result and still removed emails that had a words like 'Repeat' or 'Reorder' in the subject.

     

    Please âœ… Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item.
    If the content was useful in other ways, please consider answering Yes to Was this reply helpful? or give it a Like! 🩷
    _______________________________
    Reza M. Rizvi
    Reza M. Rizvi
    LinkedIn  |  Email
  • Suggested answer
    Haque Profile Picture
    3,653 on at
    Hi @Alema,
     
    Good to hear the the second one worked.
     
    The first one failed becuase of RE is capitalized in the email subject, " subject<>'RE:'"
     
     
    If you are sure that RE will capitalized, you can change the first expression a bit (to get the benefit of startsWith) in the condion like:
    not(startswith(tolower(subject), "RE:"))
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
  • rezarizvii Profile Picture
    352 on at
    Hi @Haque,
     
    Search Query expects a KQL query and NOT native Power Automate Expressions. It will just ignore the Power Automate Expression and either return all emails or return none.
     
    References: 
     
    Thank you.
  • Suggested answer
    Alemax Profile Picture
    24 on at
    After a long time, I finally got it: 
    -subject:\"RE: \"
  • rezarizvii Profile Picture
    352 on at
    @Alemax, glad you found a solution. 

    For some reason, I could not figure out a way to make the query accept double quotes or a colon. :(
     
    Thanks for the update. I will keep that in mind.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard