cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Knapster
Level: Powered On

Extract plain text from the body of an email

Hi, I'm having trouble trying to create a flow that will extract plain text from an email and adding the information to Power BI

 

I have the link between Flow and Power BI working but im stuck on the expression so I can add the relevant text to the datafield.

 

The email is already arriving in plain text, example below:

 

CUSTOMER: Bill Gates

 

REFERENCE: REF1234

 

TYPE: Fuel

 

USAGE: Domestic

 

QUANTITY: 1250 litres

PRICE: £506.25

 

I've tried using:  substring(body('Html_to_text'),add(lastIndexOf(body('Html_to_text'),'CUSTOMER '), 10),25)

 

But I dont need to use the HTML converter as the email body is already plain text

 

Any help would be appriciated

2 REPLIES 2
Dual Super User
Dual Super User

Re: Extract plain text from the body of an email

Hi!

Let's assume each row is delimited by a new line.  If so, one alternative is to use split function 

splitSplits the string using a separator. For example, this function returns ["a", "b", "c"]:

split('a;b;c',';')

 

 

If you manage to first identify new line characters (this is the tricky part) you will have each row as an independent element of the output array. Then you need to apply the same strategy per row; but in this case using ":" as the separator.

 

There are several threads in this community discussing how to identify new line characters, like this one:

https://powerusers.microsoft.com/t5/Building-Flows/Replace-Newline-in-Flow-Expression/m-p/58873

 

Hope this helps



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Community Support Team
Community Support Team

Re: Extract plain text from the body of an email

Hi @Knapster,

 

Which relevant text do you want to extract from the email body?

Could you please share a screenshot of your flow’s configuration?

I think it is necessary to add “HTML to text” action in your flow, because, Microsoft Flow would get body message as a html format, the screenshot as below:

 

I assume that you want to extract “Bill Gates” text, I have made a test on my side and please take a try with the following workaround:12.JPG

 Within Input field of “Compose” action, please type the following formula:

substring(body('Html_to_text'),add(lastIndexOf(body('Html_to_text'),'CUSTOMER'), 10),10)

 

The flow works successfully as below:13.JPG

 

More details about the usage of expression, please check the following article:

https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language

 

 

Best regards,

Kris

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

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

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!

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 Solution Authors
Top Kudoed Authors
Users online (5,280)