'The "MailTo" ...setting a proper name on the Recipient

How do I set a proper name for the recipient when in HTML I want to use the "mailto" tag.

Something like:

mailto:"John Wayne([email protected])?subject..

How do I achieve that ??



Solution 1:[1]

The original standard for mailto: links, RFC 1738, says this:

A mailto URL takes the form:

mailto:<rfc822-addr-spec>

where <rfc822-addr-spec> is (the encoding of an) addr-spec, as specified in RFC 822 [6].

Under that definition, addr-spec is of the form "local-part@domain", so no proper name could be included.

But the mailto: section of RFC 1738 was first superseded by RFC 2368, which allows (among other things, including predefined subject lines) for an RFC 822 mailbox specification—which includes a proper name.

[2016-05-31] As David Balažic points out in a comment, RFC 2368 is in turn obsoleted by RFC 6068. From Section 9, “Main Changes from RFC 2368”:

The main changes from RFC 2368 are as follows:

An RFC 5322 <addr-spec> is of the same "local-part@domain" form as mentioned above, so once again, no name can officially be included.

In actual use, mailto:Fred Foo<[email protected]> still seems to work, but it’s not officially supported; you may also have to encode the space, i.e., mailto:Fred%20Foo<[email protected]>, and/or put the name in quotes, i.e., mailto:"Fred Foo"<[email protected]>.

Solution 2:[2]

Try this: mailto:%22John%20Wayne%22%[email protected]%3e?subject..

Wrap the name in %22 and the email has %3c before it and %3e after it and %20 for spaces

That will output: "John Wayne"<[email protected]>

Full list of URL Encoding here: http://www.w3schools.com/tags/ref_urlencode.asp

Solution 3:[3]

I tried

mailto:John Wayne<[email protected]>?subject...

and it seems to work.

Solution 4:[4]

As mentioned in other answers, RFC 2368 allows the full mailbox syntax, which can be in name-addr (display-name plus angle-addr) form (RFC 5322). Unfortunately, it was obsoleted by RFC 6068, which only allows addr-spec form. However, both specifications allow omitting the URI authority (where the to-address usually goes) and specifying full header fields (including To:) as query parameters. Therefore, mailto:?to=John%20Wayne%20%[email protected]%3e is valid.

Solution 5:[5]

  <a href="mailto:lala lala2([email protected])?subject=MailTo Comments&[email protected]&[email protected]">ddddd</a>

Remember to use only one ? (question mark), when providing multiple entries beyond e-mail address

Solution 6:[6]

This all depends on what mail client you use. I've tried that long before at Outlook express and it's ok. But after many years, I use Dream Mail and it will only bring in the mail address part while leave out the name part.

Solution 7:[7]

Encode the uri and assign it to mailto.

Also your email and display name need to be formed as either John Wayne <[email protected]> or [email protected] (John Wayne).

Make sure you did encodeURI for these. Else it wont work properly in different mailclients.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jonathan Hartley
Solution 2
Solution 3 SF Developer
Solution 4 Community
Solution 5
Solution 6 Scott Chu
Solution 7