Hi,

I am consuming emails with attachments in my application but I need to write
the contents of the attachments out to an endpoint. 

Here is my route : 

 from("imap://user@mail.server?password=password")
        .routePolicy(startPolicy).noAutoStartup()
        .process(new MyMailProcessor())
        .to("file:/tmp/mailout/");

Here is MyMailProcessor as per (http://camel.apache.org/mail.html) : 

public class MyMailProcessor implements Processor
{

  @Override
  public void process(Exchange exchange) throws Exception
  {
    // the API is a bit clunky so we need to loop
    Map<String, DataHandler> attachments =
exchange.getIn().getAttachments();

    if (attachments.size() > 0)
    {
      for (String name : attachments.keySet())
      {
        DataHandler dh = attachments.get(name);
        // get the file name
        String filename = dh.getName();

        // get the content and convert it to byte[]
        byte[] data = exchange.getContext().getTypeConverter()
            .convertTo(byte[].class, dh.getInputStream());

        // write the data to a file
        FileOutputStream out = new FileOutputStream(filename);
        out.write(data);
        out.flush();
        out.close();
      }
    }
  }
}

However, for some reason the file contents are no longer being written to
/tmp/mailout. I say no longer because about a week ago I did have it working
but for some reason, it now writes it out to the directory where the
application is executing from and no longer written to the destination
.to("file:/tmp/mailout/");

Any ideas?

Thanks



--
View this message in context: 
http://camel.465427.n5.nabble.com/Custom-processor-result-not-passed-to-endpoint-tp5731425.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to