You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by tide08 <sa...@yahoo.com> on 2010/03/12 21:01:17 UTC

Camel-Mail: Alternative part does not handle charset?

It looks like the mail component does not support charset handling for
alternative part? I can set Content-Type for main body but MailBinding does
not extract out charset from Content-Type?

Class: MailBinding

{code}
protected void createMultipartAlternativeMessage(MimeMessage mimeMessage,
MailConfiguration configuration, Exchange exchange)
        throws MessagingException, IOException {

        MimeMultipart multipartAlternative = new
MimeMultipart("alternative");
        mimeMessage.setContent(multipartAlternative);

        BodyPart plainText = new MimeBodyPart();
        plainText.setText(getAlternativeBody(configuration, exchange));
        // remove the header with the alternative mail now that we got it
        // otherwise it might end up twice in the mail reader
       
exchange.getIn().removeHeader(configuration.getAlternativeBodyHeader());
        multipartAlternative.addBodyPart(plainText);
{code}

But it should instead be -

 plainText.setText(getAlternativeBody(configuration, exchange), charset);

Please let me know if I am missing something obvious and there is way to
specify it?

Thanks!

-- 
View this message in context: http://old.nabble.com/Camel-Mail%3A-Alternative-part-does-not-handle-charset--tp27882178p27882178.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel-Mail: Alternative part does not handle charset?

Posted by tide08 <sa...@yahoo.com>.
Forgot to mention that this was for v2.2.0

I have raised JIRA - https://issues.apache.org/activemq/browse/CAMEL-2545
along with patch to fix it.

Please feel free to drop it, if there is already an alternate way to handle
this.

Thanks!


tide08 wrote:
> 
> It looks like the mail component does not support charset handling for
> alternative part? I can set Content-Type for main body but MailBinding
> does not extract out charset from Content-Type?
> 
> Class: MailBinding
> 
> {code}
> protected void createMultipartAlternativeMessage(MimeMessage mimeMessage,
> MailConfiguration configuration, Exchange exchange)
>         throws MessagingException, IOException {
> 
>         MimeMultipart multipartAlternative = new
> MimeMultipart("alternative");
>         mimeMessage.setContent(multipartAlternative);
> 
>         BodyPart plainText = new MimeBodyPart();
>         plainText.setText(getAlternativeBody(configuration, exchange));
>         // remove the header with the alternative mail now that we got it
>         // otherwise it might end up twice in the mail reader
>        
> exchange.getIn().removeHeader(configuration.getAlternativeBodyHeader());
>         multipartAlternative.addBodyPart(plainText);
> {code}
> 
> But it should instead be -
> 
>  plainText.setText(getAlternativeBody(configuration, exchange), charset);
> 
> Please let me know if I am missing something obvious and there is way to
> specify it?
> 
> Thanks!
> 
> 

-- 
View this message in context: http://old.nabble.com/Camel-Mail%3A-Alternative-part-does-not-handle-charset--tp27882178p27883915.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel-Mail: Alternative part does not handle charset?

Posted by tide08 <sa...@yahoo.com>.
@willem

Sorry, it took longer but I have updated the patch (have not test it for
2.3.0) on JIRA.

Thanks! 


willem.jiang wrote:
> 
> Hi,
> 
> I just have a look at the patch, and I can't just copy the java file 
> into the repository, as there are some change on the MailBinding.java 
> since Camel 2.2.0 release, so please send a diff patch which is based on 
> the current trunk.
> 
> Thanks for your contribution.
> 
> Willem
> 
> tide08 wrote:
>> I already had patch with JIRA, and I just added a TestCase. 
>> 
>> Thanks!
>> 
>> 
>> willem.jiang wrote:
>>> +1 for this change, can you submit a patch with an unit test.
>>> I will be happy to apply it into the trunk :)
>>>
>>> Willem
>>>
>>> tide08 wrote:
>>>> Just wanted to check, if this patch/fix made sense? Anyone?
>>>>
>>>> Thanks!
>>>>
>>>>
>>>>
>>>> tide08 wrote:
>>>>> It looks like the mail component does not support charset handling for
>>>>> alternative part? I can set Content-Type for main body but MailBinding
>>>>> does not extract out charset from Content-Type?
>>>>>
>>>>> Class: MailBinding
>>>>>
>>>>> {code}
>>>>> protected void createMultipartAlternativeMessage(MimeMessage
>>>>> mimeMessage,
>>>>> MailConfiguration configuration, Exchange exchange)
>>>>>         throws MessagingException, IOException {
>>>>>
>>>>>         MimeMultipart multipartAlternative = new
>>>>> MimeMultipart("alternative");
>>>>>         mimeMessage.setContent(multipartAlternative);
>>>>>
>>>>>         BodyPart plainText = new MimeBodyPart();
>>>>>         plainText.setText(getAlternativeBody(configuration,
>>>>> exchange));
>>>>>         // remove the header with the alternative mail now that we got
>>>>> it
>>>>>         // otherwise it might end up twice in the mail reader
>>>>>        
>>>>> exchange.getIn().removeHeader(configuration.getAlternativeBodyHeader());
>>>>>         multipartAlternative.addBodyPart(plainText);
>>>>> {code}
>>>>>
>>>>> But it should instead be -
>>>>>
>>>>>  plainText.setText(getAlternativeBody(configuration, exchange),
>>>>> charset);
>>>>>
>>>>> Please let me know if I am missing something obvious and there is way
>>>>> to
>>>>> specify it?
>>>>>
>>>>> Thanks!
>>>>>
>>>>>
>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Camel-Mail%3A-Alternative-part-does-not-handle-charset--tp27882178p27950879.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel-Mail: Alternative part does not handle charset?

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I just have a look at the patch, and I can't just copy the java file 
into the repository, as there are some change on the MailBinding.java 
since Camel 2.2.0 release, so please send a diff patch which is based on 
the current trunk.

Thanks for your contribution.

Willem

tide08 wrote:
> I already had patch with JIRA, and I just added a TestCase. 
> 
> Thanks!
> 
> 
> willem.jiang wrote:
>> +1 for this change, can you submit a patch with an unit test.
>> I will be happy to apply it into the trunk :)
>>
>> Willem
>>
>> tide08 wrote:
>>> Just wanted to check, if this patch/fix made sense? Anyone?
>>>
>>> Thanks!
>>>
>>>
>>>
>>> tide08 wrote:
>>>> It looks like the mail component does not support charset handling for
>>>> alternative part? I can set Content-Type for main body but MailBinding
>>>> does not extract out charset from Content-Type?
>>>>
>>>> Class: MailBinding
>>>>
>>>> {code}
>>>> protected void createMultipartAlternativeMessage(MimeMessage
>>>> mimeMessage,
>>>> MailConfiguration configuration, Exchange exchange)
>>>>         throws MessagingException, IOException {
>>>>
>>>>         MimeMultipart multipartAlternative = new
>>>> MimeMultipart("alternative");
>>>>         mimeMessage.setContent(multipartAlternative);
>>>>
>>>>         BodyPart plainText = new MimeBodyPart();
>>>>         plainText.setText(getAlternativeBody(configuration, exchange));
>>>>         // remove the header with the alternative mail now that we got
>>>> it
>>>>         // otherwise it might end up twice in the mail reader
>>>>        
>>>> exchange.getIn().removeHeader(configuration.getAlternativeBodyHeader());
>>>>         multipartAlternative.addBodyPart(plainText);
>>>> {code}
>>>>
>>>> But it should instead be -
>>>>
>>>>  plainText.setText(getAlternativeBody(configuration, exchange),
>>>> charset);
>>>>
>>>> Please let me know if I am missing something obvious and there is way to
>>>> specify it?
>>>>
>>>> Thanks!
>>>>
>>>>
>>
>>
> 


Re: Camel-Mail: Alternative part does not handle charset?

Posted by tide08 <sa...@yahoo.com>.
I already had patch with JIRA, and I just added a TestCase. 

Thanks!


willem.jiang wrote:
> 
> +1 for this change, can you submit a patch with an unit test.
> I will be happy to apply it into the trunk :)
> 
> Willem
> 
> tide08 wrote:
>> Just wanted to check, if this patch/fix made sense? Anyone?
>> 
>> Thanks!
>> 
>> 
>> 
>> tide08 wrote:
>>> It looks like the mail component does not support charset handling for
>>> alternative part? I can set Content-Type for main body but MailBinding
>>> does not extract out charset from Content-Type?
>>>
>>> Class: MailBinding
>>>
>>> {code}
>>> protected void createMultipartAlternativeMessage(MimeMessage
>>> mimeMessage,
>>> MailConfiguration configuration, Exchange exchange)
>>>         throws MessagingException, IOException {
>>>
>>>         MimeMultipart multipartAlternative = new
>>> MimeMultipart("alternative");
>>>         mimeMessage.setContent(multipartAlternative);
>>>
>>>         BodyPart plainText = new MimeBodyPart();
>>>         plainText.setText(getAlternativeBody(configuration, exchange));
>>>         // remove the header with the alternative mail now that we got
>>> it
>>>         // otherwise it might end up twice in the mail reader
>>>        
>>> exchange.getIn().removeHeader(configuration.getAlternativeBodyHeader());
>>>         multipartAlternative.addBodyPart(plainText);
>>> {code}
>>>
>>> But it should instead be -
>>>
>>>  plainText.setText(getAlternativeBody(configuration, exchange),
>>> charset);
>>>
>>> Please let me know if I am missing something obvious and there is way to
>>> specify it?
>>>
>>> Thanks!
>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Camel-Mail%3A-Alternative-part-does-not-handle-charset--tp27882178p27913696.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel-Mail: Alternative part does not handle charset?

Posted by Willem Jiang <wi...@gmail.com>.
+1 for this change, can you submit a patch with an unit test.
I will be happy to apply it into the trunk :)

Willem

tide08 wrote:
> Just wanted to check, if this patch/fix made sense? Anyone?
> 
> Thanks!
> 
> 
> 
> tide08 wrote:
>> It looks like the mail component does not support charset handling for
>> alternative part? I can set Content-Type for main body but MailBinding
>> does not extract out charset from Content-Type?
>>
>> Class: MailBinding
>>
>> {code}
>> protected void createMultipartAlternativeMessage(MimeMessage mimeMessage,
>> MailConfiguration configuration, Exchange exchange)
>>         throws MessagingException, IOException {
>>
>>         MimeMultipart multipartAlternative = new
>> MimeMultipart("alternative");
>>         mimeMessage.setContent(multipartAlternative);
>>
>>         BodyPart plainText = new MimeBodyPart();
>>         plainText.setText(getAlternativeBody(configuration, exchange));
>>         // remove the header with the alternative mail now that we got it
>>         // otherwise it might end up twice in the mail reader
>>        
>> exchange.getIn().removeHeader(configuration.getAlternativeBodyHeader());
>>         multipartAlternative.addBodyPart(plainText);
>> {code}
>>
>> But it should instead be -
>>
>>  plainText.setText(getAlternativeBody(configuration, exchange), charset);
>>
>> Please let me know if I am missing something obvious and there is way to
>> specify it?
>>
>> Thanks!
>>
>>
> 


Re: Camel-Mail: Alternative part does not handle charset?

Posted by tide08 <sa...@yahoo.com>.
Just wanted to check, if this patch/fix made sense? Anyone?

Thanks!



tide08 wrote:
> 
> It looks like the mail component does not support charset handling for
> alternative part? I can set Content-Type for main body but MailBinding
> does not extract out charset from Content-Type?
> 
> Class: MailBinding
> 
> {code}
> protected void createMultipartAlternativeMessage(MimeMessage mimeMessage,
> MailConfiguration configuration, Exchange exchange)
>         throws MessagingException, IOException {
> 
>         MimeMultipart multipartAlternative = new
> MimeMultipart("alternative");
>         mimeMessage.setContent(multipartAlternative);
> 
>         BodyPart plainText = new MimeBodyPart();
>         plainText.setText(getAlternativeBody(configuration, exchange));
>         // remove the header with the alternative mail now that we got it
>         // otherwise it might end up twice in the mail reader
>        
> exchange.getIn().removeHeader(configuration.getAlternativeBodyHeader());
>         multipartAlternative.addBodyPart(plainText);
> {code}
> 
> But it should instead be -
> 
>  plainText.setText(getAlternativeBody(configuration, exchange), charset);
> 
> Please let me know if I am missing something obvious and there is way to
> specify it?
> 
> Thanks!
> 
> 

-- 
View this message in context: http://old.nabble.com/Camel-Mail%3A-Alternative-part-does-not-handle-charset--tp27882178p27910864.html
Sent from the Camel - Users mailing list archive at Nabble.com.