camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From borgel <borge.lo...@gmail.com>
Subject How to add attachement
Date Tue, 15 Jan 2008 11:34:58 GMT

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://smtp.host.com?from=user.name@address.com")
	    	        	.setHeader("subject", constant("My subject"))	    	        	    	        
	    	        	.recipientList(header("receipients"))
	    	        .otherwise().to("ftp://admin@localhost?password=xxx");
	    	    }
	        };
	        
	        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.


Mime
View raw message