Search code examples
htmlemailhyperlinkoutlookbookmarks

Link to section not working on HTML-rich Outlook email


I am sending an email with a table that lists all system exceptions that I catch. For each row, the error should link to the corresponding row on the next table with its full stack trace.

So, I created a link like that (consider error code 999, for example):

<a href="#e999">Error 999</a>

And, the target section like this:

<h2 id="e999" name="e999">Error 999</h2>

The email is sent perfectly, and displayed correctly, but the link just doesn't work at Outlook. I have already gone to view source and copy pasted into an html file to test on Chrome, and it works fine!

On my research I just found a StackOverflow answer containing exactly what I tried.

Any ideas?


Solution

  • There is a Microsoft support page regarding how to Add a hyperlink to an email message. Reading it, you'll find that you wanted, in other words, to Insert a bookmark in the current message.

    As a way to troubleshoot the issue, you could follow the steps, and create the bookmark manually, just to test if it would work... And it worked! So, why did it work? Viewing the generated working source code, you'll find the difference: it seems that Outlook just support anchors as targets:

    Link to section:

    <a href="#e999">Error 999</a>
    

    Target section:

    <h2><a id="e999" name="e999">Error 999</a></h2>
    

    Pheeew! - Everything's working now!