RE: Using java mail to send email with subject in chinese (from Unicode)

From: Dean Harding (dean.harding@dload.com.au)
Date: Mon Feb 28 2005 - 16:13:41 CST

  • Next message: David J. Perry: "RE: Script Continuums (Was: Re: Greek glyphs)"

    Well, first of all, if you're putting Unicode into the subject, your
    encoding should be "UTF-16BE" or "UTF-8" or something like that, not
    "ISO-8859-1".

    I don’t know if java mail supports quoted-words for encoding MIME
    headers, but if not you can always encode the subject yourself. See
    RFC2047 (http://www.faqs.org/rfcs/rfc2047.html) for details, but
    basically you can just go:

    ssg.setSubject("=?utf-8?B?<subject encoded in Base64>?");

    But then again, I would assume that since the setSubject method takes an
    encoding name as an argument, that putting the right value in there
    should work...

    Dean.

    -----Original Message-----
    From: unicode-bounce@unicode.org [mailto:unicode-bounce@unicode.org] On
    Behalf Of Brian Gould
    Sent: Tuesday, 1 March 2005 7:14 am
    To: unicode@unicode.org
    Subject: Using java mail to send email with subject in chinese (from
    Unicode)

    My system currently uses html escapes to send email text in any language
    – most recently Chinese.  But this approach doesn’t work for email
    subjects.  When I attempt to simply send the subject using:

    msg.setSubject(subjectStringInUnicode, “ISO-8859-1”);

    This should work, but I’ve also tried “big5”.

    Sometimes I get an exception that the data cannot be encoded, and other
    times it just seems corrupt.  Is there some kind of trick to this that
    someone can share?



    This archive was generated by hypermail 2.1.5 : Mon Feb 28 2005 - 16:16:34 CST