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 / Extracting specific te...
Power Automate
Unanswered

Extracting specific text from email body

(0) ShareShare
ReportReport
Posted on by 59

Hi,

 

I am trying to set up a flow to extract specific lines from the body of an email.

I currently want all information highlighted in red to point to specific columns within sharepoint:  

 

Column 1:

Short description: Suspicious Domain Registration Identified:
EXAMPLE-Uk-Plc[.]com

Description:

 

Column 2:

Domain Registered:
* EXAMPLE-Uk-Plc[.]com (34.102.136.180, Geo-location: Missouri - Kansas
City)
Date of registration:

 

Currently I have tried to only extract the text for column 1 and have come up with the following: 

 

Compose:

length(body('Html_to_text'))

Compose 2: 

add(indexOf(body('Html_to_text'),'Short Description:'),18)

Compose 3:

indexOf(body('Html_to_text'),'Description')

Compose 4: 

substring(body('Html_to_text'),outputs('Compose_2'),sub(outputs('Compose_3'),outputs('Compose_2')))

 

The I have the output rom compose 4 in the Column 1 option when creating an item in sharepoint.

 

I seem to be getting an error due to the length of the substring being too long and am unsure how to fix this. The whole email is quite lengthy so not sure if I'm breaking it down correctly and my end point isnt specific?

 

Any help would be appreciated and any more info needed please ask.

 

Thank you,

Devin

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @Devinm501 

     

    Didn't understand fully about your requirement.

     

    Short description: Suspicious Domain Registration Identified:
    EXAMPLE-Uk-Plc[.]com

     

    This all in one text?

     

     

  • Devinm501 Profile Picture
    59 on at

    Hi @abm 

     

    Apologies if i haven't explained very well. Basically i want to send the text in red (Which sits within an email) to a column in sharepoint: 

     

    Column 1:

    Short description: Suspicious Domain Registration Identified:
    EXAMPLE-Uk-Plc[.]com

    Description:

     

    the way ive tried to do this is basically separate everything from the end of the colon "Short Description:" and take all the text up until the word "Description". for some reason i can't get this working and appear to be getting an error due to the length of the substring being above 2197.

     

    does that explain any better?

     

    Thank you in advance.

  • Verified answer
    abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @Devinm501 

     

    Please see below.

     

    image.png

     

    Above expression I used is as follows:

    first(Split(last(split(outputs('Compose'),'Short description:')),'Description:'))

     

    Thanks

  • TheHobo Profile Picture
    13 on at

    Thanks - this worked great for me as well when looking to extract text between two different keywords. 

     

    I don't exactly understand how it works though, out of curiosity more than necessity, i'd be keen to understand what's happening in this code. (I do understand the commands individually)

     

    Thanks in advance

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @TheHobo 

     

    Glad that its helpful. I will make a tutorial video about expressions and let you know.

     

    Thanks

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi  @TheHobo 

     

    Here is the video which I promised earlier. In my demo I have used the expressions individually in a compose action step which is easy to understand. Of course you can combine multiple expressions into one action step like I did here for the solution. 

     

    My tutorial link for Power Automate Expression Split(), First() & Last()

     

    Power Automate - Expressions - Split, First & Last - YouTube

     

    Thanks

     

  • TheHobo Profile Picture
    13 on at

    Thankyou so much - that was very informative! Much appreciated

  • TheHobo Profile Picture
    13 on at

    It appears that the formulaes used above start searching from bottom to top, which means if an email is replied to with the same table/criteria (with the old emails below), it still picks up the data in the older email. 

     

    How do I get it to search from top to bottom? 

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Could you post a screen shot of the sample email?

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 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard