web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Conditional removal of...
Power Automate
Answered

Conditional removal of the tail of an email thread

(1) ShareShare
ReportReport
Posted on by 34

Hi,

I want to be able to collect the first part of email threads.

Any thoughts how to do this?

 

The condition that should decided where to do the cut is typically "Best regards", "Br", but also other key words may be there.

If there is no hit on any of these, the complete email body should be provided as output.

 

So, what I believe I need is something like 

     first(split(<the text body>, <recursive check against a list of delimiters>))

But, as this does not work, I need another solution.

 

Help very much appreciated!

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @olsamuel 

     

    first(split(<the text body>, 'Best regards'))

     

    This will give you the message before the 'Best regards'

     

    You can check whether it's null then return the full body using an IF condition.

     

    Thanks

  • olsamuel Profile Picture
    34 on at

    Thanks abm, this gives me one of the options and that I am familiar with.

     

    The tricky thing for me is a solution where the delimiter may be one of many in a gross list.

    I can of course repeat first-split with the explicit ones, but thought it would be nicer with a solution that checked against a list of delimiters.

    Any thoughts?

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @olsamuel 

     

    You can declare your expected delimiters in a Compose. Next I used the split( ) to convert it into an array. Then iterate each item from the array to use the split() expression against the email body. See below.

     

    Try the below steps:

     

    image.png

     

    Above Compose2 expression is

     

    split(outputs('Compose'),',')
     
    Compose 3
     
    first(split(triggerOutputs()?['body/body'],item()))
     
    Note: Extend the flow by adding an IF condition to check whether the Compose 3 output is empty or not? If not empty then store that in a variable to get the output.
     
    Hope it helps.
     
    Thanks
  • olsamuel Profile Picture
    34 on at

    Hi,

    Again very much appreciating that you try to help me on this.

     

    Couple of things

    1. I added a condition on the Compose 3, with the check if the result is empty or not (null). It seems when there is no hit against the delimiter list, the Compose 3 uses the full body as the output. So all Delimiters runs True.
    How to manage? Maybe another check if a match against the delimiter list is achieved or not?

    2. Is there a way to run end the loop when the first delimiter match happens? Maybe "Do Until"? 

     

    Thanks!

     

  • Verified answer
    abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @olsamuel 

     

    Thanks for your reply. Ok I understood what you are saying. Great point. So what you could do is once you done split() it gives you an array. Check the array length using the expression length(). If its one means it didn't find the delimiter. If it more than one means it find the delimiter. I think that will do it nicely.

     

    Thanks

  • olsamuel Profile Picture
    34 on at

    Yes and thanks, I tried it out and it works. Still so that the split expression does not result in a length zero, but rather the original email body. But the length() function still works as you can compare between resulting and original length, The resulting length should be shorter when there is a delimiter match. 

     

    Much appreciated your effort!

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @olsamuel 

     

    Thanks for accepting the solution.

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard