I'm using camel 2.7.3 and a stringtemplate, but I could use an other template
if that would be useful.
My code looks like:

onException(ZipFormatException.class).handled(true)
.to("file:" + errorDir.toString()) //move corrupted zip to another directory
.process(mailBuilder)
.to("string-template:corruptedzipMail.tm")//doesn't work, attachment lost
.to("smtp:"+ mailEndpoint);

Processor mailBuilder = new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
                File file = ExchangeHelper.getMandatoryInBody(exchange, 
File.class);
                exchange.getIn().setHeader("subject",
                                Builder.constant("CAMEL TEST mail"));
                exchange.getIn().addAttachment(file.getName(),
                                new DataHandler(new FileDataSource(file)));
        }
};


Claus Ibsen-2 wrote
> 
> Hi
> 
> What version of Camel are you using? And which template components are
> you using?
> Maybe post a snippet of your route.
> 
> 
> 
> On Fri, Jan 6, 2012 at 11:32 AM, LNB <lnijbijvank@> wrote:
>> In my camel route I download and unpack zip files. When something goes
>> wrong,
>> I want to send a mail with the zip file that has gone wrong as an
>> attachment. I want to construct the body of this mail using a template.
>>
>> When I first add the zip file as an attachment to the message and next
>> route
>> it to a template, the attachment is lost. When I first route the message
>> to
>> the template, I lose the zipfile as message body and can't add it as
>> attachment.
>>
>> Is it possible to use a template with an attachment?
>>
>> --
>> View this message in context:
>> http://camel.465427.n5.nabble.com/How-to-send-a-templated-mail-with-attachment-tp5125167p5125167.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
> 


--
View this message in context: 
http://camel.465427.n5.nabble.com/How-to-send-a-templated-mail-with-attachment-tp5125167p5125742.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to