mailto special characters

2019-01-17 01:38发布

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

标签: html mailto
9条回答
Viruses.
2楼-- · 2019-01-17 01:57

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:mail@coretrek.no?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.

查看更多
对你真心纯属浪费
3楼-- · 2019-01-17 02:02

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.

查看更多
该账号已被封号
4楼-- · 2019-01-17 02:04

rawurlencode() function works best with outlook, tested with Firefox, Chrome & IE

查看更多
Animai°情兽
5楼-- · 2019-01-17 02:04

If one is using SharePoint 2010, it seems Microsoft has been aware of this issue, and has supplied some functions to solve this.

The following will properly escape the link to the current page

escapeProperly(escapeProperlyCoreCore($(location).attr('href'), false, false, true))

查看更多
神经病院院长
6楼-- · 2019-01-17 02:06

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?

查看更多
姐就是有狂的资本
7楼-- · 2019-01-17 02:10

You need to enable UTF-8 support for the mailto: protocol

From the main outlook window, click Tools -> Options -> mail format -> international options -> "Enable UTF-8 support for mailto: protocol".

查看更多
登录 后发表回答