cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EricC
Level 8

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
Community Support Team
Community Support Team

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
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!
Community Support Team
Community Support Team

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.
EricC
Level 8

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?

Community Support Team
Community Support Team

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
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (6,735)