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 specific text ...
Power Automate
Answered

Extract specific text from Outlook and Add a new row to Excel

(0) ShareShare
ReportReport
Posted on by 13

Hi, 

 

I am using the HTML to Text function to extract text from Email and I would like to extract specific text into excel by using Add a row into a table. However, my data is not capturing correctly. I think it is because i am extracting text from the Email subject first. Please help to advise.

 

I tried several method and my Data 2 seems to always combine with Data 3 

Data 3 will pick up the signature part which i do not require

 

Email Text

Date: 27/01/2023

ID: TEST123456789

Thanks & Best Regards,

Alicia

 

Excel Table

noobiesaurus_0-1674805230476.png

Add a row into a table

noobiesaurus_1-1674805645437.png

 

Data 1 is using the following expression as i would like to extract specific text from the subject of an email that is within ()

slice(triggerOutputs()?['body/subject'], add(nthIndexOf(triggerOutputs()?['body/subject'], ' ', 7), 2), indexOf(triggerOutputs()?['body/subject'], ')'))

 

Data 2 

27/1/2023

 

Data 3

TEST123456789

Categories:
I have the same question (0)
  • grantjenkins Profile Picture
    11,063 Moderator on at

    I'm assuming you could have other text within the body of the email. Hopefully this will get what you're looking for.

     

    I'm using the same Table structure as you have provided.

    grantjenkins_1-1674826806528.png

     

    Below is the email I used for testing.

    grantjenkins_0-1674826777059.png

     

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

    grantjenkins_2-1674826837691.png

     

    Html to text is what you've already used to strip out the HTML.

    grantjenkins_3-1674826873355.png

     

    Select converts the data to an array and trims any leading/trailing spaces. The expressions used are below. Also note that Map is set to Text mode (see screenshot).

    //From
    split(outputs('Html_to_text')?['body'], decodeUriComponent('%0A'))
    
    //Map
    trim(item())
    
    //Note that decodeUriComponent('%0A') refers to new line characters.

    grantjenkins_4-1674827029239.png

     

    Filter array Date will filter the array to only include items that start with "Date:" The expression used is:

    item()

    grantjenkins_5-1674827102073.png

     

    Filter array ID will filter the array to only include items that start with "ID:" The expression used is:

    item()

    grantjenkins_6-1674827155280.png

     

    Add a row into a table uses the following expressions to extract out the data.

    //Data1
    slice(triggerOutputs()?['body/subject'], add(indexOf(triggerOutputs()?['body/subject'], '('), 1), indexOf(triggerOutputs()?['body/subject'], ')'))
    
    //Data2
    trim(last(split(first(body('Filter_array_Date')), ':')))
    
    //Data3
    trim(last(split(first(body('Filter_array_ID')), ':')))

    grantjenkins_7-1674827254216.png

     

    The output after running the flow after receiving an email.

    grantjenkins_8-1674827326808.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.

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

    I redone it as felt my original solution (although does work) is a bit long and convoluted. Here's a much more streamlined solution.

     

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

    grantjenkins_9-1674827979772.png

     

    Html to text is what you've already used to strip out the HTML.

    grantjenkins_10-1674827996079.png

     

    Add a row into a table uses the following expressions to extract our data.

    //Data1
    slice(triggerOutputs()?['body/subject'], add(indexOf(triggerOutputs()?['body/subject'], '('), 1), indexOf(triggerOutputs()?['body/subject'], ')'))
    
    //Data2
    trim(first(split(last(split(outputs('Html_to_text')?['body'], 'Date:')), decodeUriComponent('%0A'))))
    
    //Data3
    trim(first(split(last(split(outputs('Html_to_text')?['body'], 'ID:')), decodeUriComponent('%0A'))))

    grantjenkins_11-1674828082829.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.

  • noobiesaurus Profile Picture
    13 on at

    Hi @grantjenkins 

     

    Thank you for the solution which it worked as a charm!

    I have another question... different sender may word the data differently like below... 

    how may I write the various possibilities into the expression?

     

    Dates: 27/01/2023

    Name ID: TEST123456789

     

    Date: 27/01/2023

    ID Name: TEST123456789

     

    Dated: 27/01/2023

    ID.Name: TEST123456789

  • grantjenkins Profile Picture
    11,063 Moderator on at

    We could do it for the following:

    • Date
      • Starts with 'Date' - would handle all options you provided above.
    • Name ID
      • Contains ID and Name - would they always have both ID and Name in the header?
      • Starts with Name or Starts with ID - would handle all options you provided above, but not sure if other data in the email might also start with Name or ID.
  • noobiesaurus Profile Picture
    13 on at

    Hi @grantjenkins 

     

    This option looks good, what would the expression be like? I provided just an example, sometimes the email sender may send something more than just Name or ID. The rest of the email will not start with these text.

    • Starts with Name or Starts with ID - would handle all options you provided above, but not sure if other data in the email might also start with Name or ID.
  • grantjenkins Profile Picture
    11,063 Moderator on at

    If the users can enter whatever they want (multiple permutations) then it's really difficult to cater for all options. I would suggest trying to see how you could get users to maybe fill out a form, or similar, so that the results were consistent.

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
Vish WR Profile Picture

Vish WR 873

#2
Valantis Profile Picture

Valantis 822

#3
Haque Profile Picture

Haque 482

Last 30 days Overall leaderboard