Outlook does not handle multibyte characters when using mailto:

I have a similar problem as described in this question: I am using the mailto protocol to open the default mail client from Java (I am tied to Java 5, so unfortunately I cannot use the Desktop API ).

Some emails contain Japanese text. The strings are already UTF-8 encoded like this:

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

      

Japanese characters are correctly encoded into their URL equivalents, so "ๅนณ" becomes, for example, "% E5% B9% B3"; however, when Outlook opens a new mail window, the 3-byte character is interpreted as three different characters - so "% E5% B9% B3" is interpreted as "รฅยนยณ".

I'm pretty sure the issue has to do with the look and feel, as the following HTML snippet has the same effect (SO doesn't seem to allow emails inside tags, so I can't provide a link directly, sorry):

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

      

Long story short, how can I convince Outlook to interpret multibyte characters correctly when they come from a mailto link?

EDIT: To answer Johannes' question: we have a Java application that sends an 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 problem; but in this case it is necessary that the user can customize the letter before sending.

If anyone can suggest a method cmd.exe

to create the same effect (a new mailbox with a pre-filled tag and body) - and given that we're tied to Java 5, so the Desktop API is unfortunately not an option - I would be very happy!

+1


source to share


5 answers


You can try this:

There is an option: Enable UTF-8 support for mailto protocol: in Outlook @



Tools> Options> Mail Format> International Options> [x] Enable UTF-8 support for mailto: protocol

Hope this works for you.

+1


source


The object works for me in Windows Live Mail, but there is no recipient display name. When everything is UTF-8 encoded, Android works fine, but Windows Live Mail shows some characters in "To:" while "Subject:" is correct. When I use UTF-16 for "To:" Windows Live Mail works now, but Android still receives it as UTF-8 ...



+1


source


You are not specifying any encoding, so Outlook (or whoever gives the Outlook address) can only guess. In the case of your HTMl snippet, try specifying the encoding (UTF-8) explicitly in <head>

this behavior.

As far as cmd is concerned, it can't handle UTF-8. It treats Unicode as UTF-16, albeit with problems though.

When I try to do this here (Windows Live Mail, not Outlook) everything in the theme is converted to a legacy code page, so the CJK should be a problem.

However, I'm wondering why you are trying to misuse cmd

so that the user can write mail anyway. There are definitely better alternatives out there (although I currently don't know one because I never really needed it).

0


source


I am assuming your Java mailer is working fine , but of course try switching to JavaMail .

Check out this post. Outlook 2003 does not correctly recognize the character encoding of HTML emails by default (in many cases) even though they contain the appropriate tag:

 <meta http-equiv="content-type" content="text/html; charset=UTF-8">

      

You can switch to Outlook 2007 and / or open mail in an editor and configure the message properties:

  • open message
  • Edit -> Edit message
  • Format -> Encoding -> choose a new encoding
  • File -> Save

Edit: Corrections after changing the question.

Edit2: Sorry, didn't read the full question.

I see you have a limitation on Java 5, but if the implementation is also tied to Windows, consider using a JNI / JNA solution (unfortunately I can't give you links to that). I would also like to take a look at the OpenJDK Desktop API implementation and extract the path from it.

Another option is to somehow pass the message without URLEncoding?

Also, if the user needs to customize the message before sending, you can provide a simple editor for this in your application and send the message via JavaMail.

You can also suggest a collaborative way to prepare a message for the user, put it on the clipboard and open the mail client for the user. Then the user only needs to issue CTRL + V to paste the prepared text.

0


source


Mailto: link must use RFC2047 encoding, not UTF. http://en.wikipedia.org/wiki/MIME

Email:???? Me@example.com Header == UTF-8 In aGVsbG8 =

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

0


source







All Articles