tags:

views:

1525

answers:

6

Is there a way to make the email client ( Outlook ) accept special characters coming from the mailto link in html? I'm trying to have a mailto link with german characters in the body, but in Outlook I get only strange characters.

Thanks

A: 

It sounds like you need the page containing the mailto link to be in the encoding that Outlook is expecting. Without knowing any more about the situation, I'd try encoding the page in UTF-8 and ISO-8859-1.

The relevant 'more about the situation' would be what weird characters appear and what the page's encoding is currently.

chaos
+2  A: 

I think using a urlencode method should do what you're looking for. JavaScript has .encodeURI() methods on string objects, and .NET has the HttpUtility.UrlEncode method.

What language are you using?

John Weldon
A: 

I have a problem like this. I fixed the problem with Outlook but now Thunderbird is not displaying it correctly. I hope this is not a flavor of each one :(

labilbe
Can you post your solution?
Armitage
Since both email clients have different behaviors, I used a workaround which finds special chars and transform it to a normal one (if possible)
labilbe
+1  A: 

I just spent 2 days investigation this issue. Our issue was that mailto: links on our utf-8 encoded web pages did not work for Outlook users if the subject= string contained non-ascii characters, like e.g Norwegian characters. An example is: "mailto:[email protected]?subject=julegløgg og fårikål"

From what I have learned so far, Outlook simply does not handle anything other than ASCII and iso-8859-1 characters. So when trying to click on the above mailto link (either from IE or Firefox), Outlook fails to decode the characters, leaving the subject broken and containing "weird" characters.

So the next step was to try to re-encode the pages in ISO-8859-1. What we did was to replace the original mailto link on the utf-8 page with a link to a "email-to-iso"-service, like this:

http://url.com/service.php?service=util.mailtoencode&mailto=mail%40coretrek.no%3Fsubject%3Demne+%C3%B8%C3%A6%C3%A5+emne

This page would convert the mailto characters to iso-8859-1 and then output the entire page content in iso-8859-1. A javascript on the page, containing "location.href='mailto:...'" was used to open the client's email client automatically.

So far everything seemed ok. This actually works in Internet Explorer, both with Thunderbird and Outlook (tested on IE7 on WinXP with Outlook express and TB 2).

BUT the problem now is actually Firefox. It seems like Firefox is unable to decode url-encoded urls containing characters found only in ISO-8859-1 but not in ASCII (like the norwegian å, represented by %E5 when encoded). The same å is handled correct if the page encoding is utf-8, but it seems like the Firefox developers have forgotten to test special characters together with the ISO-8859-1 charset. The result is that Firefox passes an un-decoded string (still containing %E5 intstead of å) to the email client. And, amazingly, this is handled correct by Outlook (which manages to decode the string itself), but NOT by Thunderbird, which probably has the same bug as Firefox. If you DON't url encode the subject, the string is passed correctly to Thunderbird, but not to Outlook.

We have also been trying other encoding methods, like php's htmlentities, htmlspecialchars, base64 encoding etc, but all of them fails one way or the other.

So, summarized:

Pages encoded in utf-8:

IE fails always

FF -> Thunderbird: OK

FF -> Outlook: FAIL

Pages encoded in iso-8859-1:

IE: OK

FF -> Thunderbird: Fails if subject is url encoded, ok if not)

FF -> Outlook: Fails if subject is not url encoded, ok if encoded) (this is Windows, on Ubuntu Linux FF and TB works OK always).

Hoping this was helpful for others having the same problem.

Arve Skjørestad
A: 

Actually, the solution is http://blogs.msdn.com/ie/archive/2007/02/12/International-Mailto-URIs-in-IE7.aspx and it is not nice.

Basically, in IE 7 and 8 the user must have enabled an advanced setting in Internet Options, something that 100% of the users will not know will not have enabled.

yandr
A: 

In PHP I think the function that works best with Outlook is rawurlencode()

Mario Chueca