users@javamail.java.net

Re: multiple 'Re: ' prefixed in replies

From: <xoot123_at_yahoo.it>
Date: Mon, 1 Jul 2013 08:42:08 +0100 (BST)

I omitted a detail, the application that adds multiple 'Re: ' is the same I'm working on, it was a test sending a message to my address with the  same application and replying back multiple times.

As the application just calls reply() on the IMAPMessage, I see the prefix is added each time. That's how I think it works, I'll however give a look at the code again to be sure nothing more is done on the message. And I'll try your workaround too.

I'm not getting, though, your warning about always using utf-8: if I manipulate the message through JavaMail APIs, shouldn't it work with the set charset?



Thanks
M. R.






>________________________________
> Da: Bill Shannon <bs00011_at_gmail.com>
>A: xoot123_at_yahoo.it
>Cc: "users_at_javamail.java.net" <users_at_javamail.java.net>
>Inviato: Giovedì 27 Giugno 2013 19:31
>Oggetto: Re: multiple 'Re: ' prefixed in replies
>
>
>
>xoot123_at_yahoo.it wrote on 06/27/2013 05:55 AM:
>
>Hello,
>>when I receive an email whose subject has accented letters (i.e. "ripròva") the first reply shows the subject "Re: ripròva", but the next reply to the latter shows "Re: Re: ripròva", adding another prefix.
>>This is because in the actual email text the subject header is like "Subject: =?UTF-8?Q?Re:_ripr=C3=B2va?=", so I guess that the existing "Re: " isn't detected by Javamail and another one is prefixed.
>>
>>
>>When the subject is shown in the application it looks fine, so the utf-8 encoding is properly decoded.
>>
>>
>>Is this something that can be fixed with a JavaMail parameter? Should I manipulate somehow the subject before invoking reply()?
The code currently has this comment:
>
>        /*
>         * Have to manipulate the raw Subject header so that we
      don't lose
>         * any encoding information.  This is safe because "Re:"
      isn't
>         * internationalized and (generally) isn't encoded.  If
      the entire
>         * Subject header is encoded, prefixing it with "Re: "
      still leaves
>         * a valid and correct encoded header.
>         */
>
>There's really no need to encode the word "Re:", so applications that do so are just being lazy.  I suppose JavaMail could decode the header first, and then prepend an unencoded "Re:" to the encoded header if necessary.
>
>As a workaround you can use getSubject() on the reply message and
    strip off multiple instances of "Re:" and use setSubject() on the
    result.  That will work fine as long as all the encoding information
    is correct in the original message and you're willing to always use
    utf-8 for the reply message.
>
>
>
>