使用 mailto 时 Outlook 不处理多字节字符: [英] Outlook not processing multi-byte characters when using mailto:

查看:35
本文介绍了使用 mailto 时 Outlook 不处理多字节字符:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类似的问题 在这个问题中描述:我正在使用mailto"协议从 Java 打开默认邮件客户端(我现在绑定到 Java 5,很遗憾我不能使用 Desktop API).

部分电子邮件包含日语文本.字符串已经被 UTF-8 编码如下:

private void email(String to, String subject, String body){String encodingSubject = URLEncoder.encode(subject, "UTF-8");String encodingBody = URLEncoder.encode(body, "UTF-8");String mailto = "mailto:" + to + "?subject=" + encodingSubject +"&body=" + 编码体;String cmd = "cmd.exe/c start "" "" + mailto + """;Runtime.getRuntime().exec(cmd);}

日语字符被正确编码为它们的 URL 等价物,所以平"变成了%E5%B9%B3",例如;但是,当 Outlook 打开新邮件窗口时,三字节字符被解释为三个不同的字符 - 因此%E5%B9%B3"被解释为å¹³".

我相当确信问题出在 Outlook 上,因为以下 HTML 代码段产生了相同的效果(因此似乎不允许在标签内使用 mailto,因此我无法直接提供链接,抱歉):

<身体><a href="mailto:foo@bar.com?subject=%E5%b9%B3">点我测试!</a>

简而言之,当多字节字符来自 mailto 链接时,我如何说服 Outlook 正确解释它们?

回答 Johannes 的问题:我们有一个 Java 应用程序,它会在执行某些操作时发送电子邮件.每封电子邮件的标准文本都是从资源包中提取的,在大多数情况下,我们使用 JavaMail API 没有任何问题;但在这种情况下,要求用户在发送之前能够定制电子邮件.

如果有人可以建议一种非cmd.exe 方式来产生相同的效果(带有主题和正文预填充的新邮件窗口) - 并记住我们与 Java 5 相关,所以遗憾的是,桌面 API 不是一种选择 - 我会很高兴!

解决方案

mailto: 链接应该使用 RFC2047 编码而不是 UTF.http://en.wikipedia.org/wiki/MIME

mailto:me@example.com?subject==?UTF8?B?aGVsbG8?=

http://webnet77.com/cgi-bin/helpers/base-64.pl

I have similar problem to the one described in this question: I am using the "mailto" protocol to open the default mail client from Java (I am tied to Java 5 for now, so sadly I can't use the Desktop API).

Some of the emails contain Japanese text. The strings are already being UTF-8 encoded as follows:

private void email(String to, String subject, String body)
{
    String encodedSubject = URLEncoder.encode(subject, "UTF-8");
    String encodedBody = URLEncoder.encode(body, "UTF-8");

    String mailto = "mailto:" + to + "?subject=" + encodedSubject + 
        "&body=" + encodedBody;
    String cmd = "cmd.exe /c start "" "" + mailto + """;
    Runtime.getRuntime().exec(cmd);
}

The Japanese characters are correctly encoded to their URL-equivalents, so "平" becomes "%E5%B9%B3", for example; however, when Outlook opens the new mail window, the three-byte character is interpreted as three distinct characters - so "%E5%B9%B3" is interpreted as "å¹³".

I am fairly convinced the problem lies with outlook, since the following HTML snippet produces the same effect (SO doesn't seem to allow mailto inside tags, so I can't provide the link directly, sorry):

<html>
    <body>
    <a href="mailto:foo@bar.com?subject=%E5%b9%B3">click me to test!</a>
    </body>
</html>

In short, how can I persuade Outlook to interpret multi-byte characters correctly when they're coming from a mailto link?

EDIT: To answer Johannes' question: we have a Java app which sends email when certain actions are performed. The standard text for each email is pulled from resource bundles, and in most cases we use the JavaMail API without any problems; but in this one case, there is a requirement for the user to be able to tailor the email before sending.

If anyone can suggest a non-cmd.exe way of producing the same effect (new mail window with subject and body prefilled) - and bearing in mind that we are tied to Java 5, so the Desktop API is sadly not an option - I would be very happy!

解决方案

The mailto: link should use RFC2047 encoding rather than UTF. http://en.wikipedia.org/wiki/MIME

mailto:me@example.com?subject==?UTF8?B?aGVsbG8?=

http://webnet77.com/cgi-bin/helpers/base-64.pl

这篇关于使用 mailto 时 Outlook 不处理多字节字符:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆