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

Extract text from body from body of an email

It seems that this has already been asked many times, but I can't find a solution to my problem.

I'm trying to extract the text highlighted in red.

The body looks like this after using "HTML_to_Text"

 

Segnalato da: cristian Commento: Problema di sicurezza Posizione: San MIchele\TO, 10100 Torino TO, Italia

 

What I need is to extract the text from "Segnalato da:" to "Commento:". From "Commento:" to "Posizione:". And from "Posizione:" to the end of the mail.

My difficulty is that the length of the text is variable, from 1 character to 500. Only the words "Segnalato da:" "Commento:" and "Posizione:" remain fixed

 

can you help me?

Thanks

Cristian

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Extract text from body from body of an email

Hi  @Webfire ,

 

Please refer to screenshot below to create the flow:

1.png

 

The expression in the Compose 2 as below:

 

last(split(first(split(outputs('Compose'),'Commento:')),'Segnalato da:'))

The expression in the Compose 3 as below:

last(split(first(split(outputs('Compose'),' Posizione:')),' Commento:'))

The expression in the Compose 4 as below:

last(split(outputs('Compose'),' Posizione:'))

When send an email with the body message that you provided, the flow would run successfully as below:

1.png

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
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

9 REPLIES 9
Highlighted
Super User III
Super User III

Re: Extract text from body from body of an email

Hi @Webfire ,

 

Here it is. 

 

First you need to initialize the text in a variable. Then use the Split expression to split the values into array.

 

split1.png

 

Above copy the below Split function. Here I am using two pipe characters as separator.

 

split(replace(replace(replace(variables('EmailText'), 'Segnalato da: ', ''), ' Commento: ','||'), ' Posizione: ', '||'), '||')
 
This stage all the values are pushed into an array. Next extract the values. See the example below I did for Segnalatoda. Please note the expression function. Change the index value 0,1& 2 to get other values accordingly.
 
split2.png
 
Please let me know how it goes.
 

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

 
 

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials
Highlighted
Helper I
Helper I

Re: Extract text from body from body of an email

Thanks @abm  for the reply.

I am a beginner and I find it difficult to find the "split texts with keywords" function. I imagine it is in the list of variables, but I only have these:


Append to array variable

Append to string variable

Decrement variable

Increment variable

Initialize variable

Set the variable value

 

Where i find the function?

 

Thanks

Cristian

Highlighted
Super User III
Super User III

Re: Extract text from body from body of an email

H

Hi @Webfire ,

 

What you need to do the following:

Add the initialise varaible. Type the name as TextSplits, Select the Type as Array and next click the value text field. Then on the right hand side click the expression and type or copy and paste the following:

 

split(replace(replace(replace(variables('EmailText'), 'Segnalato da: ', ''), ' Commento: ','||'), ' Posizione: ', '||'), '||')

split3.png

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

 

 

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials
Highlighted
Super User III
Super User III

Re: Extract text from body from body of an email

Hi @Webfire ,

 

Forgot to mention about renaming the variable names or flow step. Click the three dots and click rename. Enter a meaningful name for your flow step. So here I did added an initialise variable and renamed to 'Split Texts with Keywords'

 

split4.png

 

 

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

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials
Highlighted
Community Support
Community Support

Re: Extract text from body from body of an email

Hi  @Webfire ,

 

Please refer to screenshot below to create the flow:

1.png

 

The expression in the Compose 2 as below:

 

last(split(first(split(outputs('Compose'),'Commento:')),'Segnalato da:'))

The expression in the Compose 3 as below:

last(split(first(split(outputs('Compose'),' Posizione:')),' Commento:'))

The expression in the Compose 4 as below:

last(split(outputs('Compose'),' Posizione:'))

When send an email with the body message that you provided, the flow would run successfully as below:

1.png

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
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

Highlighted
Super User III
Super User III

Re: Extract text from body from body of an email

Hi @Webfire ,

 

Do you need anymore help in this? 

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials
Highlighted
Helper I
Helper I

Re: Extract text from body from body of an email

Works great!

 

Thanks for your help

Cristian

Highlighted
Helper I
Helper I

Re: Extract text from body from body of an email

Hi @abm

I still need your help. For several days an error has appeared in the Flow you created for me. But now the flow have an error

Cattura.PNG

Expanding the variable "Posizione" i see this error:

Cattura1.PNG

The Box "Initialize variable", at the beginning of the flow, have this value:

Name: EmailText

Type: String

Value: Segnalato da: Cristian Nallino Commento: mail di conferma per il pagamento
Posizione: No address available

 

You can help me?

 

Thanks

Cristian 

Highlighted
Super User III
Super User III

Re: Extract text from body from body of an email

Hi @Webfire 

 

Do you still need help? Looks like it is expecting two array values and second one is missing.



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog

Power Automate Video Tutorials

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (7,683)