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 / Extract email from bod...
Power Automate
Answered

Extract email from body of text with different endings

(0) ShareShare
ReportReport
Posted on by 200

Hello All.

 

I receive an email that always looks like this:

 

Name = Test User
email = test.user@polkcountywi.gov
address = test address
request = Test
Client IP = 63.237.54.114

 

 

I would like to extract the email of the submitter and reply to that person. I read this post: Solved: Extract text from Body of an email in Flow - Power Platform Community (microsoft.com) but it extracts by number of characters. These emails could be of varying length and from any service so I am unsure how to get the whole email each time.

Categories:
I have the same question (0)
  • Pochoide Profile Picture
    111 on at

    If the email body looks always exactly like that, you can split the text in the linebreaks (using its ASCII code %0A), take the second component ([1]) of the resulting array and split again on the string (' = '), and finally take again the second component.

     

    So, the expression will be something like:

    split(split(triggerBody()['text'], decodeUriComponent('%0A'))[1], ' = ')[1]
     
    Pochoide_0-1678294702491.png

     

    -------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

  • apaulso9 Profile Picture
    200 on at

    @Pochoide I am sorry. I am a bit lost. Am I filtering an array? How else would indexing using [1] work? 

  • VictorIvanidze Profile Picture
    13,079 on at

    Function split() creates array of strings.

  • apaulso9 Profile Picture
    200 on at

    @VictorIvanidze I keep receiving an error saying I can't index using [1] because it is an array. Does that make sense to you? 

    Error:

    Unable to process template language expressions in action 'Compose' inputs at line '0' and column '0': 'The template language expression 'split(split(outputs('Html_to_text')?['body'],decodeUriComponent('%0A'))[3],'=')[1]' cannot be evaluated because array index '1' is outside bounds (0, 0) of array. Please see https://aka.ms/logicexpressions for usage details.'.

  • Pochoide Profile Picture
    111 on at

    It's okay. When you use the split(text, separator) function, it breaks the first argument string (text) into an array of substrings, which are delimited by the second argument string (separator). So even though you pass the email body as a string it'll return an array.

     

    Here, you can see the Split() Documentation for further explanation.

     

    Edit: The problem was that the email body is in html, you have to convert it to simple text.

    Pochoide_0-1678307764387.png

    Also, I recommend adding the trim() function to remove any remaining spaces. The expression results:

    trim(split(split(body('Html_a_texto'), decodeUriComponent('%0A'))[1], '=')[1])

     

  • Verified answer
    Pochoide Profile Picture
    111 on at

    @apaulso9  I add this as an edit in the other reply, but in case you missed it:

     

    The problem was that the email body is in html, you have to convert it to simple text.

    Pochoide_0-1678308099367.png

     

    Also, I recommend adding the trim() function to remove any remaining spaces. The expression results:

    trim(split(split(body('Html_a_texto'), decodeUriComponent('%0A'))[1], '=')[1])

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 630

#2
Valantis Profile Picture

Valantis 420

#3
11manish Profile Picture

11manish 350

Last 30 days Overall leaderboard