.HTML editing to remove pieces and replace

I am currently using the ‘For Each Email’ activity in Outlook 365 to get ‘CurrentEmail.BodyAsHtml()’ and am trying to replace specific pieces of it with either a tab or a new line to make it easier to use in creating a data table.

After getting the .BodyAsHtml() I am trying to use ‘Modify Text’ and replace the first section with “”.

I am running into the issue where it starts with ‘@"…’ and the Expression Editor will not error out due to the lack of closing “” and the ‘@’. Is there a way I can enclose the string I am trying to find other than “”?

@Gaven_Carta

If your project is using VB then you don’t need to pass @ symbol to the string.

You can try replacing string without the symbol like this.

YourString.Replace("value1", "New Value")

@Gaven_Carta,

You can enclose the HTML string in triple quotes to avoid issues with @"…". Use the expression:

YourVariable.Replace("""<tag or html part>""", "")

Alternatively, assign the target HTML snippet to another string variable and use that variable in Replace() for cleaner handling.

Hello @Gaven_Carta try this like if you want to replace a block of HTML inside the email body then use this
cleanBody = CurrentEmail.BodyAsHtml.Replace("YourExactTextHere", "")

And if the text contains quotes then escape them using
cleanBody = CurrentEmail.BodyAsHtml.Replace("<div class=""someclass"">", "")

And if it contains line breaks or tabs then use this
cleanBody = CurrentEmail.BodyAsHtml.Replace("<br>", Environment.NewLine)

Cheers

Since the information is static every time I ended up using:

CurrentEmail.BodyAsHtml.Substring(670)

Taking out the beginning section that I was having the issue with. After it I just replaced the other text with qualifying data table elements.

Thank you all,

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.