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

Split email after converting it into text

Hi, Guys.

 

After receiving the mail, it has been converted to text.

Email always contains fixed keywords.

I want to divide by keywords.

But the problem is that the number of letters in the email is different every time.

 

The following is an example.

 

Dear ABCDE:

I have reserved a nonsmoking room for you.

INFORMATION:
It is only a one-minute walk from the nearest station and a five-minute walk from the venue. I don't believe you will have any trouble accessing the site.

NOTICE:
The URL of the hotel is www.newyorkblahblahblahcityinn.co.co. Please note the attached information about the room rate and conditions, and let me know whether you are satisfied with the room.

Sincerely yours,
QWERT YUIOP

What I want to do is to extract the sentences above and below "INFORMATION:" and the sentences below "NOTICE:" respectively.

Dear ABCDE:

I have reserved a nonsmoking room for you.
INFORMATION:
It is only a one-minute walk from the nearest station and a five-minute walk from the venue. I don't believe you will have any trouble accessing the site.
NOTICE:
The URL of the hotel is www.newyorkblahblahblahcityinn.co.co. Please note the attached information about the room rate and conditions, and let me know whether you are satisfied with the room.

Sincerely yours,
QWERT YUIOP

I think that "INFORMATION:" and "NOTICE" should be searched using indexof.

If I do not know the number of characters, what should I specify?

 

Thanks.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

Hi @soooofunny ,

 

You need to use string manipulation to achieve your requirement.

 

I did built a flow and here are the steps.

 

First trigger is email arrives. Then we need to cleanup the HTML tags fromt the body of the email.

 

ms1.png

 

Next steps are the string manipulations.

 

ms2.png

indexOf(body('Html_to_text'),'INFORMATION:')

 

ms3.png

indexOf(body('Html_to_text'),'NOTICE:')
 
ms4.png
indexOf(body('Html_to_text'),'Sincerely yours')

ms5.png
sub(variables('indexnotice'),variables('indexinformation'))
ms6.png
 
replace(substring(body('Html_to_text'),variables('indexinformation'),variables('informationtextlength')),'INFORMATION:','')
ms7.png
 
sub(variables('indexsincerelyyours'),variables('indexnotice'))
 
ms8.png
replace(substring(body('Html_to_text'),variables('indexnotice'),variables('noticetextlength')),'NOTICE:','')
 
Here are my test results:
 
ms9.pngms10.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

View solution in original post

3 REPLIES 3
Super User III
Super User III

Hi @soooofunny ,

 

You need to use the string manipulation expressions here. 

 

Here is the flow I did and it did worked as expected.

 

First trigger is email arrives. Then we need to cleanup the HTML tags from the body of the email.

 

ms1.png

 

So at this stage we have a clean plain text of the email body.

 

Next we need to start using the position of each texts and extracting the texts. 

 

ms2.png

The expression I used for the above value is:  indexOf(body('Html_to_text'),'INFORMATION:')

ms3.png

The expression I used for the above value is: indexOf(body('Html_to_text'),'NOTICE:')

 

ms4.png

The expression I used for the above value is: indexOf(body('Html_to_text'),'Sincerely yours')

 

ms5.png

The expression I used for the above value is: sub(variables('indexnotice'),variables('indexinformation'))

 

ms6.png

 

The expression I used for the above value is: replace(substring(body('Html_to_text'),variables('indexinformation'),variables('informationtextlength')),'INFORMATION:','')

 

ms7.png

The expression I used for the above value is: sub(variables('indexsincerelyyours'),variables('indexnotice'))

 

ms8.png


The expression I used for the above value is: replace(substring(body('Html_to_text'),variables('indexnotice'),variables('noticetextlength')),'NOTICE:','')

 

Here are my test results.

ms9.pngms10.png

 

Let me know how you get on with this.

 

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
Super User III
Super User III

Hi @soooofunny ,

 

You need to use string manipulation to achieve your requirement.

 

I did built a flow and here are the steps.

 

First trigger is email arrives. Then we need to cleanup the HTML tags fromt the body of the email.

 

ms1.png

 

Next steps are the string manipulations.

 

ms2.png

indexOf(body('Html_to_text'),'INFORMATION:')

 

ms3.png

indexOf(body('Html_to_text'),'NOTICE:')
 
ms4.png
indexOf(body('Html_to_text'),'Sincerely yours')

ms5.png
sub(variables('indexnotice'),variables('indexinformation'))
ms6.png
 
replace(substring(body('Html_to_text'),variables('indexinformation'),variables('informationtextlength')),'INFORMATION:','')
ms7.png
 
sub(variables('indexsincerelyyours'),variables('indexnotice'))
 
ms8.png
replace(substring(body('Html_to_text'),variables('indexnotice'),variables('noticetextlength')),'NOTICE:','')
 
Here are my test results:
 
ms9.pngms10.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

View solution in original post

Hi, @abm .

 

Thank you for your kindness.

I thought that it might not be possible to realize this matter.

But that covered with a great answer.

 

My hope has come true, so I will finish it.

 

Thanks.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Top Kudoed Authors
Users online (10,856)