cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EricC
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

 

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

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!
v-bacao-msft
Community Support
Community Support

 

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.

@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?

 

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.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (6,289)