You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Andreas A." <an...@gmail.com> on 2016/11/09 09:44:05 UTC
camel-mail: Body ends up as attachment instead of e-mail body in
multipart mail.
I'm trying to send an e-mail with a subject, body and attached file. The
subject and attached file works fine. However when I make an attachment, the
body of the email ends up as an unnamed attachment in the final mail.
Is this a bug in Camel or do I need to do something to make sure the
Camel-body becomes a "bodyPart" and not an attachment?
Example route:
from("direct:sendReportEmailRoute")
.routeId("sendReportEmailRoute")
.setProperty("originalBody", body())
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
FileDataSource file = new
javax.activation.FileDataSource("H:\\file.txt");
in.addAttachment("report.txt", new DataHandler(file));
in.setBody("Hello");
}
})
.to("smtp:xxx?to=xxx@xxx.com,andreasasmuss@gmail.com&from=noreply@xxx.dk&subject=Your
report")
.setBody(simple("${property.originalBody}"));
--
View this message in context: http://camel.465427.n5.nabble.com/camel-mail-Body-ends-up-as-attachment-instead-of-e-mail-body-in-multipart-mail-tp5789939.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-mail: Body ends up as attachment instead of e-mail body
in multipart mail.
Posted by jmaurin <j....@gmail.com>.
Hello,
we had got the same problem (ie a attachement file as body).
To resolve it, we have 'force' the content type in the header as :
in.setHeader("contentType", "text/plain");
Best regards,
jmaurin
Camel version : 2.14.1
--
View this message in context: http://camel.465427.n5.nabble.com/camel-mail-Body-ends-up-as-attachment-instead-of-e-mail-body-in-multipart-mail-tp5789939p5790005.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-mail: Body ends up as attachment instead of e-mail body in
multipart mail.
Posted by Claus Ibsen <cl...@gmail.com>.
Also a good idea can be to look at the existing unit tests of
camel-mail, to see how some of those does it with file attachments.
On Thu, Nov 10, 2016 at 10:18 AM, Andreas A. <an...@gmail.com> wrote:
> I'm using 2.17.3. I guess I could try 2.18.0.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-mail-Body-ends-up-as-attachment-instead-of-e-mail-body-in-multipart-mail-tp5789939p5789989.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: camel-mail: Body ends up as attachment instead of e-mail body
in multipart mail.
Posted by "Andreas A." <an...@gmail.com>.
I'm using 2.17.3. I guess I could try 2.18.0.
--
View this message in context: http://camel.465427.n5.nabble.com/camel-mail-Body-ends-up-as-attachment-instead-of-e-mail-body-in-multipart-mail-tp5789939p5789989.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-mail: Body ends up as attachment instead of e-mail body in
multipart mail.
Posted by Claus Ibsen <cl...@gmail.com>.
Not sure what Camel version you use, but tell us, and try test with
newer release.
On Wed, Nov 9, 2016 at 10:44 AM, Andreas A. <an...@gmail.com> wrote:
> I'm trying to send an e-mail with a subject, body and attached file. The
> subject and attached file works fine. However when I make an attachment, the
> body of the email ends up as an unnamed attachment in the final mail.
>
> Is this a bug in Camel or do I need to do something to make sure the
> Camel-body becomes a "bodyPart" and not an attachment?
>
> Example route:
>
> from("direct:sendReportEmailRoute")
> .routeId("sendReportEmailRoute")
> .setProperty("originalBody", body())
> .process(new Processor() {
>
> @Override
> public void process(Exchange exchange) throws Exception {
> Message in = exchange.getIn();
> FileDataSource file = new
> javax.activation.FileDataSource("H:\\file.txt");
> in.addAttachment("report.txt", new DataHandler(file));
> in.setBody("Hello");
> }
>
> })
>
> .to("smtp:xxx?to=xxx@xxx.com,andreasasmuss@gmail.com&from=noreply@xxx.dk&subject=Your
> report")
> .setBody(simple("${property.originalBody}"));
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/camel-mail-Body-ends-up-as-attachment-instead-of-e-mail-body-in-multipart-mail-tp5789939.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: camel-mail: Body ends up as attachment instead of e-mail body
in multipart mail.
Posted by "Andreas A." <an...@gmail.com>.
Thanks guys, setting the content type to text/plain did the trick.
--
View this message in context: http://camel.465427.n5.nabble.com/camel-mail-Body-ends-up-as-attachment-instead-of-e-mail-body-in-multipart-mail-tp5789939p5790037.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: camel-mail: Body ends up as attachment instead of e-mail body
in multipart mail.
Posted by AOladipupo <ai...@yahoo.com>.
you need to set the content type as part of the uri options or in the
exchange header (will overite the uri values). See modified section of your
code below:
@Override
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
FileDataSource file = new
javax.activation.FileDataSource("H:\\file.txt");
in.addAttachment("report.txt", new
DataHandler(file));
*in.setHeader("contentType", "text/html");*
in.setBody("Hello");
}
--
View this message in context: http://camel.465427.n5.nabble.com/camel-mail-Body-ends-up-as-attachment-instead-of-e-mail-body-in-multipart-mail-tp5789939p5790006.html
Sent from the Camel - Users mailing list archive at Nabble.com.