cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Resolver I
Resolver I

Extract variable length Email Data (Date + ID Number)

Hi Everyone,

 

I've been following this thread here: https://powerusers.microsoft.com/t5/Building-Flows/Extract-text-from-Body-of-an-email-in-Flow/td-p/5...and I'm able to extract the info I need, the problem is the info I need can change in length. For instance:

 

I'm using an outlook email trigger > HTML to text > initialize variable

substring(body('Html_to_text'),add(lastIndexOf(body('Html_to_text'),'Date'), 15),11)

This works but it will not work if other data changes in the body of the email since it throws the counts off...

 

An HTML to text ouput would contain:

 

 

Name:

John Smith


ID Number:

666


Office:

Ohio


Date:

8/23/2019

The issue is I really just need the ID Number and Date values, but they change and can be different lengths. 

The ID Number can be 1 digit to 6 digits and the date could be 1/1/2019 (8-10 characters)

 

Any ideas?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Extract variable length Email Data (Date + ID Number)

 

Hi @EricC ,

 

Please try this expression:

trim(last(split(body('Html_to_text'),'Date:')))

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Dual Super User
Dual Super User

Re: Extract variable length Email Data (Date + ID Number)

Hi @EricC 

 

To get the ID from the "HTML to Text" action, you need to create a variable to split the results based on "New Line" character. While creating the "enter" variable, in the value just press enter once, so that this can be used to split the "HTML to Text" response.
 
Expression Used:
split(body('Html_to_text'),variables('enter'))[7]
 
Index 7 is used because based on the response shared, after split it was getting returned at the index value 7.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Highlighted
Community Support
Community Support

Re: Extract variable length Email Data (Date + ID Number)

 

Hi @EricC ,

 

Please check this similar thread, I have provided an additional method here, please check if it helps you:

https://powerusers.microsoft.com/t5/Building-Flows/Extracting-text-from-email/td-p/334919

It does not need to calculate the length of the message content, by specifying the value to get the data you need.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Resolver I
Resolver I

Re: Extract variable length Email Data (Date + ID Number)

@v-bacao-msft This works great! Only issue is for the Date since it is the last part of the body of the email there is nothing after it to tell the expression where to stop. How would I go about solving that piece?

Highlighted
Community Support
Community Support

Re: Extract variable length Email Data (Date + ID Number)

 

Hi @EricC ,

 

Please try this expression:

trim(last(split(body('Html_to_text'),'Date:')))

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (12,214)