Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

search for specific string within email - string can contain line break

(0) ShareShare
ReportReport
Posted on by

I want to create a condition in Microsoft Flow that searches for a certain string in an e-mail body.

 

I have tried it with "body contains string" and it worked, if the string was only in one line.

Unfortunately, the mail is not structured in a user-friendly way. It can happen that blanks are missing before or after the string or that the string is even spread over two lines. I simply lack the experience with this kind of queries.

 

Does anyone here have an idea how I can best approach this?

 

Here are two examples of the string I am looking for and how it could be in the mail:

The string I am looking for: "Business Function in Department: Technical Team"

The Mail can look like this:

 

Ticket: 12345678Location: [Ohio]Account: ABC Business Function in Department:

Technical TeamReason: New Hire

 

or like this:

 

Ticket: 12345678Location: [Ohio]Account: ABC Business Function

in Department: Technical TeamReason: New Hire

 

or like this:

 

Ticket: 12345678Location: [Ohio]Account: ABCBusiness Function in

Department: Technical TeamReason: New Hire

 

Any ideas and help welcome!

  • Community Power Platform Member Profile Picture
    on at
    Re: search for specific string within email - string can contain line break

    Many thanks for the provided solution! That really helped me!

  • Verified answer
    grantjenkins Profile Picture
    11,059 Super User 2025 Season 1 on at
    Re: search for specific string within email - string can contain line break

    Hopefully this is what you're looking for.

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_0-1677574044793.png

     

    When a new email arrives is what you already have.

    grantjenkins_1-1677574833444.png

     

    Html to text removes the HTML from the Body of the email.

     

    grantjenkins_2-1677574867794.png

     

    Condition uses the following expression. It removes line breaks and spaces.

    //Removes line breaks and spaces
    replace(replace(outputs('Html_to_text')?['body'], decodeUriComponent('%0A'), ''), ' ', '')
    
    //Test to see if it contains the following
    BusinessFunctioninDepartment:TechnicalTeam
    

    grantjenkins_3-1677574991281.png


    ----------------------------------------------------------------------
    If I've answered your question, please mark the post as Solved.
    If you like my response, please consider giving it a Thumbs Up.

  • VictorIvanidze Profile Picture
    12,505 on at
    Re: search for specific string within email - string can contain line break

    Just replace all line brakes with nothing before search.

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1