You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Arnaud Marchand <a....@progeri.com> on 2015/08/21 15:06:46 UTC

org.apache.camel.component.mail.SplitAttachmentsExpression

Hi,

We are using the class
org.apache.camel.component.mail.SplitAttachmentsExpression with the new
"extractAttachments" option set to true that will be released in Camel 2.16.

It works as expected but please find below two remarks:

1) In the code, the attachment is set in the body of a new message. This
does not give you the opportunity to use something that was decoded from the
mail body and sent via a header to the splitter. I suspect that most people
will use the attachment and headers of the mail in order to determine what
to do with the attachment. Basically, it just imply to copy the original
message instead of creating a new one for the splitted attachments.

So use:

private Message extractAttachment(Message inMessage, String attachmentName)
throws Exception {
final Message outMessage = inMessage.copy();
...

Instead of:

private Message extractAttachment(Message inMessage, String attachmentName)
throws Exception {
        final Message outMessage = new DefaultMessage();
...


2) The attachment name will not be usable depending on how the attachments
names are encoded. The file by itself is OK but the file name will appear as
a string such as:

=?utf-8?B?TU5ULU1OVFJ....

This comes from the JDK mail functions that does not decode the names
directly.
An easy way to handle that is to use the MimeDecoder in order to get the
appropriate file name.

attachmentName=MimeUtility.decodeText(attachmentName);

Regards,

Arnaud







--
View this message in context: http://camel.465427.n5.nabble.com/org-apache-camel-component-mail-SplitAttachmentsExpression-tp5770897.html
Sent from the Camel Development mailing list archive at Nabble.com.