i need to remove the first line of message in power automate
[EXTERNAL] This message comes from an external organization.
My flow is below, i need to fetch the body of newly arrived message, but that body has "
[EXTERNAL] This message comes from an external organization" message as first line, want to remove first line and post rest message.
any suggestion ?
Hi @RakeeS , you can try out the approach below:
1. Convert HTML to plain text to remove all html tags.
2. The tricky part is the compose 4 - it's not empty, it's actually a new line (press Enter). We need to use this trick to capture new line character later on in our expressions. '\n' does not work in flow expressions.
3. Expression in Initialize variable step:
-> This is to find the index of the first new line (end of the first line) and add 1 to have the index of the start of the second line.
4. Expression in Compose 3:
-> Get the rest of the body starting from the start of second line.
Hi, tried but , can find body string printing two times
initialize variable :
its working partially. but getting body in two times.
Hi, @ashyriverflow , getting duplicate message at Html to text field onwards.
Inputs <p><html lang="en"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta content="ie=edge"></head><body><p><strong><span style="font-weight:bold">[EXTERNAL]</span> </strong>This message comes from an external organization.</p><div><span class="preheader" style="color:transparent; display:none; height:0; max-height:0; max-width:0; opacity:0; overflow:hidden; visibility:hidden; width:0">test message</span> <div class="container">test message<br></div></div></body></html></p> Outputs [EXTERNAL] This message comes from an external organization. test message test message
hi @RakeeS , to me, the conversion seems to be correct. There are two "test message" in the body of the email so in the plain text output we see two "test message". How does the actual email body look like?
In case if you have plain text content with you can you try the below code
last(split(variables('mailBody'),'comes from an external organization.'))
So here we're splitting by exact text and taking the second part of it.
If this post helps, please consider Accept it as the solution to help the other members find it. and Thumbsup if you find it useful in otherways
hi @RakeeS ,
The code snippet you can use in compose action and the above code snippet only removes the first line only. If body is coming twice well that should be another case to look into.