cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
shaykalyan
New Member

Extract only the text from the latest reply in an email thread when using "when a new email arrives"

Hello,

 

Is it possible to extract only the latest response in an email thread instead of the entire body? 

 

For my scenario, I need to act upon each reply to an email thread with only the content from the latest response.

 

Thanks!

6 REPLIES 6
v-yamao-msft
Community Support
Community Support

Hi @shaykalyan,

 

I am not sure with your scenario, do you want to get the content from the email every time a you get a reply?

 

Could you show me more details on your scenario for better understanding.

 

Best regards,

Mabel Mao

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

Hi Mabel,

 

Sure, I'll try to describe further what I'm after. In my scenario, I would like to use the content from the latest email response in an email thread. I know that there is the "Body" dynamic content, however, for email threads with multiple responses, the "Body" content will contain replies from earlier responses as well as the latest response.

 

For example, here is the Body from a new email: 

 

"""

Initial mail content

"""

 

Then someone replies to the thread. The dynamic Body is now:

"""

Reply content

 

---------------------------------------

TO: ....

CC: ....

Subject: ...

---------------------------------------

Initial mail content

""""

 

The next reply to the thread will again have all of the history from the email in the dynamic Body variable.

 

 

What I would like to get is only the latest response in the thread and not all the other responses as well. Is this possible without doing manual string manipulation? 

 

Thanks!

Anonymous
Not applicable

Hi, I am working on the same thing, I want to extract only the latest reply (exclude all the original body of the email). Can anyone help? Thanks!


@shaykalyan wrote:

Hello,

 

Is it possible to extract only the latest response in an email thread instead of the entire body? 

 

For my scenario, I need to act upon each reply to an email thread with only the content from the latest response.

 

Thanks!


 

SRKR
Microsoft
Microsoft

I just tried some other way and was able to get the Latest Email only. Here are the steps

 

  • Every Email will have a separator which can be either a Line or Multi Tab etc., for Example in Outlook / O365 You will have a line which in HTML refer to this 

 

<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0in 0in 0in">​

 

  • Here is what I did, Step 1
     

Capture1.JPG

 

  • Initialize Variables which we call the Delimiter, Body of the Message and Latest ResponseCapture2.JPG

     

    Capture3.JPG

     

    Capture4.JPG

     

  • Finally we call the split function with [0] which gives us the First Email as below. I use this 

 

split(variables('EmailBody'),variables('Delimiter'))[0]​

 

Capture5.JPG

 

In my case I've used a different solution.

 

When I get an email:

marcoswnunes_0-1636645928360.png

 

 I first convert the email body using "HTML to text" action:

marcoswnunes_1-1636645955729.png

 

An example of an email converted would be:

 

Test body email.

Thanks,

Mark

 

From: Paul <Paul@mycompanyname.com>
Sent: 11 November 2021 15:42
To: Mark <mark@mycompanyname.com
Subject: Subject email test

...

 

So if I split the output from my conversion above with the word 'From:' and on the same expression I get the first element from my array ([0]) it will result on the latest email. 😀

marcoswnunes_2-1636646044477.png

 

trim(split(outputs('Convert_Email_BODY_in_TEXT')?['body'],'From:')[0])
 
Trim() is optional there to remove some extra spaces. 
Brad_Hedinger
New Member

How would you go about removing from the output, any content that is above the message body, that is automatically put in by the system generating the email? Salesforce does this when emails are received in a Case, and a notification is sent to the team that said email has been received in the Case.  Screenshot example below.  I have highlighted the text to indicate what I only want to extract from the email, regardless of how long or short the highlighted text could be. Of course, blacked out private info. Thank you for the help!  -Brad

 

 

Brad_Hedinger_0-1646430340271.png

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Users online (1,638)