1 Reply Latest reply on Dec 17, 2013 11:15 AM by yanwang

    how to send file as email attachment via

    yanwang

      how to send file as email attachment by Producer template' sendBodyAndHeaders

      method?

       

      could any one give a example`??

       

      sendBodyAndHeaders("smtp://you@mymailserver.com?password=secret&From=you@apache.org", ExchangePattern.InOut, , headers);

       

      Thanks!

        • 1. Re: how to send file as email attachment via
          yanwang

          it works...

          template.send("", ExchangePattern.InOnly, new EmailProcessor());

           

          class EmailProcessor implements Processor {

           

              @Override

              public void process(Exchange exchange) throws Exception {

                  exchange.getIn().setBody("Camel rocks - TEST Please Ingore!!!");

                  exchange.getIn().addAttachment("test.pdf", new DataHandler(new FileDataSource("target/test-classes/test xxxx.pdf")));

           

              }

           

          }