I need to send a message either to an e-mail address or upload it to a ftp
server, based on some criteria. The mail message should contain a text and a
list of attachement. When uploading to a ftp server all attachement should
be uploaded to the same folder.
I decided to give Camel a try for this mission.

 - How can I add several attachment to an e-mail?
 - When uploading files to a ftp server the attachements are stored in
folders with some cryptic names. How do i specify where to store the
attachments?
 - The attachments loses their names and extension, and not readable after
upload (except for attachment only containing text).

Here is my test code:
CamelContext context = template.getContext();           
Endpoint<Exchange> endpoint = context.getEndpoint("direct:a");
Producer<Exchange> producer = endpoint.createProducer();                
Exchange exchange = endpoint.createExchange();        
exchange.getIn().setHeader("receipients", recipients);  
File file1 = new File("C:\\temp\\test.pdf");              
exchange.getIn().setBody(file1);                           
producer.process(exchange);   
producer.stop()


 protected RouteBuilder createRouteBuilder() {                  
                RouteBuilder builder = new RouteBuilder() {
                    public void configure() {
                        from("direct:a")
                        .choice().when(header("target").isEqualTo("mail"))
                                .to("smtp://[EMAIL PROTECTED]")
                                .setHeader("subject", constant("My subject"))   
                                        
                                .recipientList(header("receipients"))
                        .otherwise().to("ftp://[EMAIL PROTECTED]");
                    }
                };
                
                return builder;
            }           



-- 
View this message in context: 
http://www.nabble.com/How-to-add-attachement-tp14837954s22882p14837954.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to