I want to display the email address inside ‘<[email protected]’>’ tag in UI, how can I achieve this? How to display email address with tag in UI?
<html>
<head>
</head>
<body>
<br> I'm sorry to have to inform you that your message could not
<br> be delivered to one or more recipients. It's attached below.
<br> <[email protected]>: host mx.gmail.com[136.143.191.44] said: 550 5.1.1
<br> <[email protected]> User unknown (in reply to RCPT TO command)
<br> Reporting-MTA: dns; smtp5.to.test.com
<br> X-Postfix-Queue-ID: E982A3346F
<br> X-Postfix-Sender: rfc822; [email protected]
<br> Arrival-Date: Mon, 20 Feb 2023 17:37:11 +0530 (IST)
<br> Final-Recipient: rfc822; [email protected]
<br> Original-Recipient: rfc822;[email protected]
<br> Remote-MTA: dns; mx.zoho.com
<br> Diagnostic-Code: smtp; 550 5.1.1 <[email protected]> User unknown
</body>
</html>
It is display as in below image, not displaying email address with tag
4
Answers
Some characters are reserved in HTML.
If you use the less than (<) or greater than (>) signs in your text, the browser might mix them with tags.
Character entities are used to display reserved characters in HTML.
A character entity looks like this:
&entity_name;
OR
&#entity_number;
To display a less than sign (<) we must write: < or <
The code snippet below is how you’d update the [email protected] to some other variable. Simply use javascript to change emailHolderVariable to whatever email address you want it to be. The "<" and ">" tags (with a semi-colon on the end) mean "<" and ">" when the file is read. For a full list of these codes, please visit https://www.teachucomp.com/special-characters-in-html-tutorial. I hope this answer helps you out.
As others said, you have to escape some special characters in your text. If you are using a templating engine like Velocity there are usually build-in mechanism for proper escaping (in case of Velocity the EscapeTool.
If you use simple string concatenation you should use Apache Commons Text’s StringEscapeUtils#escapeHtml4() method or equivalent for all your text content but not for the tags.
Something like:
declare this variable
then bind it on your html file :
it works for me