Broken accented characters in MailTo Link

I'm trying to create a mailto link that contains French accented characters as the subject and body of the email. Both HTML and character encoding URIs do not work. Here is my code:

<a href="mailto:%20?subject=ce%20titre%20est%20cass%C3%A9.&body=travaux%20deja!%20cesser%20d'%C3%AAtre%20t%C3%AAtu">SEND EMAIL</a>

      

The same result occurs without URI encoding:

<a href="mailto:?subject=ce titre est cassΓ©&body=travaux deja! cesser d'Γͺtre tΓͺtu">SEND EMAIL</a>

      

No, the way I do it, a new letter opens with broken characters. URI encoded spaces and line breaks work fine, but anything that is not ANSI is broken. I should note that I am testing the English and French versions of MS Outlook 2007. Does anyone know how to get this to work?

+2


source to share


4 answers


IE 8 has the option set. Tools -> Options -> Advanced. In the International section, check the "Use UTF-8 for mail links" option.

In Windows XP, this option is disabled by default. It is enabled by default in Windows 7.



Hope it helps

+3


source


Everything in the mail header (including the subject) must be MIME encoded according to this RFC,

http://www.ietf.org/rfc/rfc2047.txt

It's not that hard, but you can find code to handle it in most languages.

Correctly encoded text looks like this:



=?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=

      

EDIT: try to see if you want,

<a href="mailto:your@email.com?subject=%3d%3fISO-8859-1%3fB%3fY2UgdGl0cmUgZXN0IGNhc3Pp%3f%3d&Content-Type=text%2fplain%3b+charset%3dISO-8859-1&body=travaux%20deja!%20cesser%20d'%C3%AAtre%20t%C3%AAtu">SEND EMAIL</a>

      

Replace the email address with your own.

+2


source


Got! This may or may not be a bug in Microsoft Outlook / Entourage. I changed my default mail reader to Mail.app and it works great with urlencoding. The error is likely (possibly) affecting one of the two accented e characters in your example. Perhaps Outlook / Entourage is not handling UTF8 mantibut characters correctly?

+1


source


For example with mootools (but could be a different framework or even raw javascript), I usually do this and it works on mac / pc with major browsers / clients:

window.addEvent('domready', function(){
    //get the links to encode
    var links_to_encode = $$('#page ul li a');

    links_to_encode.each(function(link){
        //check if the link has an href
        var original_href = link.get('href');
        if(original_href){
            //substitute it with the encoded version
            link.set('href',encodeURI(original_href));
        }
    });
});//fine domready

      

Bye!

+1


source







All Articles