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 / search for specific st...
Power Automate
Answered

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

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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!

Categories:
  • VictorIvanidze Profile Picture
    13,083 on at

    Just replace all line brakes with nothing before search.

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at

    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.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

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

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 331 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard