skip to Main Content

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

enter image description here

4

Answers


  1. 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: &lt or &#60

    Login or Signup to reply.
  2. 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 "&#60" and "&#62" 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.

    <!DOCTYPE html>
    <body>
    <p id="content-holder">random placeholder</p>
    <script>
        var emailHolderVariable = "[email protected]"
        var emailInput = "&#60;" + emailHolderVariable + "&#62; Your text here...";
        var contentHolder = document.getElementById('content-holder');
        contentHolder.innerHTML = emailInput;
    </script>
    </body>
    
    Login or Signup to reply.
  3. 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:

    String htmlFragment = "<p>" + StringEscapeUtils.escapeHtml4​(plainText) + "</p";
    
    Login or Signup to reply.
  4. declare this variable

      adress:string ='<[email protected]>'
    

    then bind it on your html file :

    <br> {{adress}}
    

    it works for me

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search