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

Community site session details

Session Id :
Power Automate - General Discussion
Answered

Remove text from body of email

(0) ShareShare
ReportReport
Posted on by 12
I am trying to remove specific text from an email and send the rest of the body of the email in a Webex chat message. I've played around with the body many different ways, but I cannot get it to work. I am attaching screenshots of the text I want removed and the flow so far. Any help would be greatly appreciated.
Categories:
I have the same question (0)
  • Suggested answer
    chiaraalina Profile Picture
    1,125 on at
    Remove text from body of email
    Hi 
     
    The main tool for this is replace().

    You can try this or similar:
     
    replace(
      replace(
        body('When_a_new_email_arrives_(V3)'),
        'CAUTION! This email originated from outside of our organization. DO NOT CLICK links or open attachments unless you recognize the sender and know the content is safe.',
        ''
      ),
      'This email contains an automatically generated notification created by your organization.',
      ''
    )
     
    Use it in a Compose action.
     
    Use the Outputs of the Compose action as the message body.
     
  • VictorIvanidze Profile Picture
    13,045 on at
    Remove text from body of email
    Google for "ModifyAndForward flow for Office 365".
  • JP-31101432-0 Profile Picture
    12 on at
    Remove text from body of email
     Unfortunately, that did not work. Also, I don't see an Outputs option, only Inputs. I am attaching images of what I added to Compose and what actually shows up from the email into Webex. I'm brand new to PowerAutomate so I very well could be missing something.
     
  • VictorIvanidze Profile Picture
    13,045 on at
    Remove text from body of email
     
    use this expression:
     
    replace(replace(triggerOutputs()?['body/body'],'CAUTION! This email originated from outside of our organization. DO NOT CLICK links or open attachments unless you recognize the sender and know the content is safe.',''),'This email contains an automatically generated notification created by your organization.','')
  • JP-31101432-0 Profile Picture
    12 on at
    Remove text from body of email
    Unfortunately, this is what I get when I use that expression. 
     
  • Suggested answer
    Tomac Profile Picture
    3,914 Moderator on at
    Remove text from body of email
     
    It looks like you're trying to take an HTML formatted message, strip the HTML out, and then send the remaining text out without two pieces.
     
    Here's a flow which accomplishes this:
     
    1) The HTML To Text action takes the Email Body
    2) The Compose runs the expression from @chiaraalina but targeting the HTML TO Text action instead of the original email body:
    replace(
      replace(
        body('Html_to_text'),
        'CAUTION! This email originated from outside of our organization. DO NOT CLICK links or open attachments unless you recognize the sender and know the content is safe.',
        ''
      ),
      'This email contains an automatically generated notification created by your organization.',
      ''
    )
     
    3) I don't have access to the same Send A Message action you have, but you'll reference the dynamic value Outputs from the previous Compose action as the message, since that's what removed the text
     
    This should accomplish your goal.
     
    If this comment resolves the issue, please remember to mark it as the answer.
  • JP-31101432-0 Profile Picture
    12 on at
    Remove text from body of email
    Thanks, we are getting closer. It's pulling in the data I need, but still have everything else there. I have highlighted in green the only parts I want to show up in the message. I am also attaching the flow that is built now. Let me know if any of it looks off. 


     
  • Verified answer
    Tomac Profile Picture
    3,914 Moderator on at
    Remove text from body of email
    @JP-31101432-0 I understand. Try this:
     
    Here's that slice expression:
    slice(body('Html_to_text'),add(indexof(body('Html_to_text'),'Rule:'),6),indexof(body('Html_to_text'),'This email contains'))
    This expression takes the full output of the HTML To Text action, finds the position of the text 'Rule:' and adds 6 to it to use as the starting location, then cuts out everything before that and everything starting at the text 'This email contains'
     
    So it should just pull the message you're looking for with nothing else included.
     
    You don't need the second Compose, I was just using that to show what you would use in your Send A Message action.
  • JP-31101432-0 Profile Picture
    12 on at
    Remove text from body of email
    That is 99% it! I thought I needed the line under Break_Exceeds..... but I need to remove it as well. What do I add in to remove that one too?
  • Suggested answer
    Tomac Profile Picture
    3,914 Moderator on at
    Remove text from body of email
    @JP-31101432-0 Here you go:
     
    slice(body('Html_to_text'),add(indexof(body('Html_to_text'),'Rule:'),6),sub(indexof(body('Html_to_text'),'This email contains'),2))
     
    To adjust, change that 2 near the end. Making it higher will cut more characters (such a line breaks) from the end, making it smaller will cut off fewer characters.

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

Coming soon: forum hierarchy changes

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
Tomac Profile Picture

Tomac 544 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 482 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 287

Last 30 days Overall leaderboard