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

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

问题描述

我有一个类似的问题,我使用mailto协议从Java打开默认邮件客户端(我现在绑定到Java 5,所以可悲的是我无法使用桌面API )。

一些电子邮件包含日语文本。这些字符串已经是UTF-8编码的,如下所示:

  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);
}

日语字符被正确编码为URL等效项,成为%E5%B9%B3但是,当Outlook打开新邮件窗口时,三字节字符被解释为三个不同的字符 - 因此%E5%B9%B3解释为å¹³。



我相信问题出在outlook,因为下面的HTML片段产生相同的效果(SO似乎不允许mailto里面的标签,所以我不能直接提供链接,对不起):

 < html> 
< body>
< a href =mailto:foo@bar.com?subject =%E5%b9%B3>点击我来测试!< / a>
< / body>
< / html>

简而言之,如何说服Outlook正确解析多字节字符mailto链接?



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



如果任何人可以建议非 - cmd.exe 生成相同效果的方式(主题和正文预填充的新邮件窗口) - 并记住我们绑定到Java 5,所以桌面API是不幸的不是一个选项 - 我会很高兴!

解决方案

在Windows Live Mail中,主题是我的,但收件人的显示名称不是。
当evertything是UTF-8编码时,Android工作正常,但Windows Live Mail在To:中显示一些符号,而Subject:正确。当我使用UTF-16为To:,Windows Live Mail现在工作,但Android仍然得到它作为UTF-8 ...


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 subject is alright for me in Windows Live Mail but the display name of the recipient not. When evertything is UTF-8 encoded, Android works fine but Windows Live Mail shows some symbols in "To:" while the "Subject:" is correct. When I use UTF-16 for "To:", Windows Live Mail works now but Android still gets it as UTF-8...

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

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