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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / search for specific st...
Power Automate
Unanswered

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!

Categories:
I have the same question (0)
  • VictorIvanidze Profile Picture
    13,073 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
    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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard