Just to help all naive users who are trying to use camel mail component-
The below code worked for me in my xbean where i am using camel mail
component-
CamelContext camel= new DefaultCamelContext();
camel.start();
camel.addComponent("mail", new
MailComponent());
MailComponent component= (MailComponent)camel.getComponent("mail");
Endpoint endpoint =
component.createEndpoint("smtp://[EMAIL
PROTECTED]<passwrd>&contentType=text/html");
create the exchange with the mail message that is multipart with a file and
a Hello World text/plain message.
Exchange exchange =
endpoint.createExchange();
Message in = exchange.getIn();
in.setBody(bodyContent);
Map map = new HashMap();
map.put("From", "[EMAIL PROTECTED]");
map.put("To", obj.getToRecipients());
map.put("cc", obj.getCcRecipients());
map.put("Subject", obj.getSubject());
in.setHeaders(map);
//create a producer that can produce the exchange (= send the mail)
Producer producer =
endpoint.createProducer();
start the producer
producer.start();
// and let it go (processes the exchange by sending the email)
producer.process(exchange);
producer.stop();
Richa Khurana wrote:
>
> Thanks for the response Chris.
> I referred the same link you sent for camel mail component.
> Although whereever code is written certain things were not made very clear
> like context, endpoint etc, i referenced other reading material and wrote
> the below code-
> CamelContext camel= new DefaultCamelContext();
> camel.start();
> camel.addComponent("mail", new
> MailComponent());
> Endpoint endpoint =
> camel.getEndpoint("smtp://[EMAIL PROTECTED]");
> // // create the exchange with the mail
> message that is multipart with
> a file and a Hello World text/plain message.
> Exchange exchange =
> endpoint.createExchange();
>
> Message in = exchange.getIn();
>
> in.setBody("444444444444444444444444444");
>
> // create a producer that can produce the
> exchange (= send the mail)
> Producer producer =
> endpoint.createProducer();
> // start the producer
> producer.start();
>
> // and let it go (processes the exchange
> by sending the email)
> // producer.process(exchange);
>
> But it throws the below exception on running the code, for line
> exchange.getIn(). Your help is highly appreciated.
> java.lang.SecurityException: Access to default session denied
> at javax.mail.Session.getDefaultInstance(Session.java:311)
> at
> org.apache.camel.component.mail.MailConfiguration.createJavaMailSender(MailConfiguration.java:129)
> at
> org.apache.camel.component.mail.MailEndpoint.createProducer(MailEndpoint.java:53)
> at
> com.thirdpillar.uploadWS.services.DocumentChopperBean.onMessageExchange(DocumentChopperBean.java:108)
> at
> org.apache.servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoint.java:235)
> at
> org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:211)
> at
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLifeCycle.java:538)
> at
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(AsyncBaseLifeCycle.java:490)
> at
> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLifeCycle.java:46)
> at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBound(DeliveryChannelImpl.java:610)
> at
> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlow.java:172)
> at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.java:167)
> at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.java:134)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
> at java.lang.Thread.run(Thread.java:595)
>
>
>
> Chris Custine (Apache) wrote:
>>
>> You can find detailed documentation and examples of using Camel Mail
>> component here: http://activemq.apache.org/camel/mail.html
>>
>> As Lars mentioned, you can also use the servicemix-mail component as
>> well.
>> Even though the documentation says it is for ServiceMix > 3.3, I believe
>> you
>> should be able to download that component from the maven repository and
>> install it in 3.2.x. You can find the new version of that component
>> here:
>> http://repo2.maven.org/maven2/org/apache/servicemix/servicemix-mail/2008.01
>>
>> Documentation for the ServiceMix mail component is here:
>> http://servicemix.apache.org/servicemix-mail.html
>>
>> Chris
>>
>> --
>> Chris Custine
>> My Blog :: http://blog.organicelement.com
>> Apache ServiceMix :: http://servicemix.apache.org
>> Apache Directory Server :: http://directory.apache.org
>>
>>
>> On Fri, Oct 31, 2008 at 4:12 AM, Richa Khurana <
>> [EMAIL PROTECTED]> wrote:
>>
>>> Also, for our deployment, we are referring to SMX 3.2.2
>>>
>>> -----Original Message-----
>>> From: Lars Heinemann [mailto:[EMAIL PROTECTED]
>>> Sent: Friday, October 31, 2008 3:05 PM
>>> To: [email protected]
>>> Subject: SPAM:Re: Using camel mail component
>>>
>>> Why camel mail?
>>> ServiceMix got it's own mail component since 3.3 release.
>>> Please refer to the component wiki for further details.
>>>
>>> Regards
>>> Lars
>>>
>>>
>>> Richa Khurana schrieb:
>>> > Hi,
>>> >
>>> > I have a simple requirement stated below-
>>> >
>>> >
>>> >
>>> > 1. I receive XML messages in my JMS queue in SMX through external
>>> > source.
>>> > 2. I unmarshall the xml and get the contents to be sent in a mail
>>> > in my xbean
>>> > 3. Now, I need to use camel mail component to send emails.
>>> >
>>> >
>>> >
>>> > Can someone help with an example of configuring mail component and
>>> > sending mails from the xbean to my mail server?
>>> >
>>> >
>>> >
>>> > Thanks,
>>> >
>>> >
>>> >
>>> > Richa Khurana| Lead - Engineering| GlobalLogic Inc.
>>> > USA | INDIA | UKRAINE | CHINA
>>> > Office: +91.120.406.2681
>>> >
>>> > www.globallogic.com <http://www.globallogic.com/>
>>> > InfoWorld Award Winner for Agile Innovation
>>> > <http://www.globallogic.com/Media/pressReleaseDetail.asp?press/65>
>>> >
>>> > Disclaimer: http://www.globallogic.com/email_disclaimer.txt
>>> > <http://www.globallogic.com/email_disclaimer.txt>
>>> >
>>> >
>>> >
>>> >
>>> >
>>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Using-camel-mail-component-tp20262009p20437654.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.