You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Gregor <gr...@channeladvisor.com> on 2012/12/14 15:20:02 UTC

How to forward multipart emails using Camel?

Hey folks,

I've got an issue where we're trying to forward an email from one system to
another, basically by reading the emails from one account, sending the
message to a processor where the headers gets altered with the correct To
headers, and then passed on to be send from another account.

This looks like it should be as simple as (not including the brackets to the
XML isn't stripped)

from
uri=imaps://imap.gmail.com?username={{email.username}}&amp;password={{email.password}}&amp;consumer.delay=6000&amp;unseen=false&amp;fetchSize=5

bean ref="myProcessor"

to
uri="smtps://smtp.gmail.com?username={{email.username}}&amp;password={{email.password}}"

The myProcessor bean is where we alter the headers (and do a couple of
non-relevant-to-this-discussion things).

The issue is when the email is more than slightly complicated (i.e. a
multipart email), the Camel mail component is just doing a toString on the
body, which results in a very small email being recieved with the body of...

javax.mail.internet.MimeMultipart@2fd77b9a

Which is obviously wrong!

Any ideas how to have Camel just send the original email with the new
headers, without altering the body at all?



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-forward-multipart-emails-using-Camel-tp5724101.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to forward multipart emails using Camel?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You can possible disable mapping mail message
mapMailMessage=false

And then work on the javax.mail.Message directly.

See a bit details at
http://camel.apache.org/mail.html



On Fri, Dec 14, 2012 at 3:20 PM, Gregor
<gr...@channeladvisor.com> wrote:
> Hey folks,
>
> I've got an issue where we're trying to forward an email from one system to
> another, basically by reading the emails from one account, sending the
> message to a processor where the headers gets altered with the correct To
> headers, and then passed on to be send from another account.
>
> This looks like it should be as simple as (not including the brackets to the
> XML isn't stripped)
>
> from
> uri=imaps://imap.gmail.com?username={{email.username}}&amp;password={{email.password}}&amp;consumer.delay=6000&amp;unseen=false&amp;fetchSize=5
>
> bean ref="myProcessor"
>
> to
> uri="smtps://smtp.gmail.com?username={{email.username}}&amp;password={{email.password}}"
>
> The myProcessor bean is where we alter the headers (and do a couple of
> non-relevant-to-this-discussion things).
>
> The issue is when the email is more than slightly complicated (i.e. a
> multipart email), the Camel mail component is just doing a toString on the
> body, which results in a very small email being recieved with the body of...
>
> javax.mail.internet.MimeMultipart@2fd77b9a
>
> Which is obviously wrong!
>
> Any ideas how to have Camel just send the original email with the new
> headers, without altering the body at all?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-forward-multipart-emails-using-Camel-tp5724101.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen