Put the system exception message in bold into an email

hello
into my project development i put send email in case of system exception with putin the message in bold so i have slect the propriety isbodyhtml as true but when the error message contains ui element the selector value is not appearing in the email screenshot below

image
image

any idea how can i put the selector with bold text in the email?
thanks

That’s because the < character that’s part of the selector makes Outlook think it’s HTML code.

Put it inside <pre> and </pre> tags, in other words…

"<pre>" + exception.Message + "</pre>"
2 Likes

Please mark my reply as the solution if it solves your issue.

i put as you said but its not working…

Try this instead…

system.web.HttpUtility.HtmlEncode(exception.Message)

Can you check
"<b>" + exception.Message + "</b>"
or
"<strong>" + exception.Message + "</strong>"

its not working…

NOT working too

What is the result of

system.web.HttpUtility.HtmlEncode(exception.Message)

You can’t just say “it’s not working” - give us details. Error message? Text shows up but wrong? Text doesn’t show up?

(You can view the email source to see that the selector is there)

One simple way of dealing with it is just to replace the < and > with [ and]

Replace(Replace(exception.Message,“<”,“[”),“>”,“]”)

1 Like

was flagged as solution, so we do have second source

with a detail description on what is not working / the result we could better help
isHtml is activated we do assume

Also combined with Pauls input to encode entities it should work.

so test bold
test encoding entities
test combined

this way is working its clear that the problem is in the caracters < and >


i try to find a way to keep them as text

Yes, as I already explained < and > are characters that are used in HTML code. So Outlook thinks the selector is HTML code, and tries to parse it.

That’s why you need to use…

system.web.HttpUtility.HtmlEncode(exception.Message)

This will convert the < and > to &lt; and &gt; so that Outlook will display it instead of trying to use it as HTML.

i have put the function as you mentioned but I got this error.
image
image

What dependencies do you have in your project?

image