sushil bharwani
sushil bharwani

Reputation: 30197

Issue with mailto link in email address containing ampersand?

I have a mailto link like that <a href="mailto:a&[email protected]" > it displays correctly on html but when we click on the link the outlook just shows a in the to address. Has anyone faced the same problem please suggest.

Upvotes: 14

Views: 28219

Answers (1)

Pekka
Pekka

Reputation: 449613

Percent encoding the string is required for IE and I assume will work across browsers. From this MSDN document:

Windows Internet Explorer 7 and later. You must percent-encode all URL-reserved characters within a mailto: address. For example, the number sign (#) is used as a fragment identifier in URLs. When processing an address such as some#[email protected], Internet Explorer copies only the portion up to the number sign into the mail client; the fragment portion including the number sign is ignored. This behavior is by design.

So you need

 <a href="mailto:a%26b_admin%40xyz.com">

As said, I expect a percent encoded address will work in all browsers, but I don't know for sure. I can confirm it works with Chrome and Thunderbird.

Upvotes: 32

Related Questions