The message body is null as the timer does not set any body.

You can set a body first with

<from ...
<setBody>
   <constant>Hello Mail</constant>
</setBody>


On Sat, Sep 14, 2013 at 8:35 AM, vsmahesh <aneesh_...@yahoo.co.in> wrote:
> Hi all,
> I am geeting the error body is null when i m trying to send mail from camel.
> My route is like,
> <from uri="timer://foo?fixedRate=true&period=60"/>
>  <to uri="Email"/>
> <bean id="Email" class="com.abc.mes.bw.cdc.EmailBodyClass"/>
>
> I tried with following process methods,but i am getting the same error
>
> @Override
>         public void process(Exchange exchng) throws Exception {
>                 CamelContext context = null;
>                 // TODO Auto-generated method stub
>
>                 ProducerTemplate template = context.createProducerTemplate();
>                 Map map = new HashMap();
>                 map.put("To", "to=om_integration_lower...@abc.com");
>                 map.put("From", "jstrac...@apache.org");
>                 map.put("Subject", "Camel rocks");
>
>                 String body = "Hello Claus.\nYes it does.\n\nRegards James.";
>
> template.sendBodyAndHeaders("smtp://smtp.td.local?username=c_mahsom&password=abcd&to=om_integration_lower...@abc.com",
> body, map);
>
>         }
>
> @Override
>         public void process(Exchange exchng) throws Exception {
>                 CamelContext context = null;
>                 // TODO Auto-generated method stub
>                 CamelContext context = null;
>             Endpoint endpoint =
> context.getEndpoint("smtp://smtp.td.local?username=c_mahsom&password=abcd&to=om_integration_lower...@abcd.com");
>                 Exchange exchange = endpoint.createExchange();
>                 Message in = exchange.getIn();
>                 in.setBody("Hello World");
>                 Producer producer = endpoint.createProducer();
>                 // start the producer
>                 producer.start();
>                 // and let it go (processes the exchange by sending the email)
>                 producer.process(exchange);
>
>         }
>
>
> Error processing exchange. Exchange[Message: [Body is null]]. Caused by:
> [java.
> lang.NullPointerException - null]
> java.lang.NullPointerException
>         at
> com.outotec.mes.bw.energyconsumption.EmailBodyClass.process(EmailBody
> Class.java:31)
>         at
> org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.
> java:101)
>         at
> org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.j
> ava:71)
>         at
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncP
> rocessorBridge.process(AsyncProcessorConverterHelper.java:61)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
> er.java:73)
>         at
> org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProc
> essor.java:122)
>         at
> org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.j
> ava:298)
>         at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:1
> 17)
>         at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelp
> er.java:73)
>         at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(Delegat
> eAsyncProcessor.java:99)
>
> kindly help me in setting the body of the mail.
> thanks
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/sending-email-getting-error-Error-processing-exchange-Exchange-Message-Body-is-null-tp5739344.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to