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

From: Dean Harding (
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

    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 ( 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...


    -----Original Message-----
    From: [] On
    Behalf Of Brian Gould
    Sent: Tuesday, 1 March 2005 7:14 am
    Subject: Using java mail to send email with subject in chinese (from

    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