On 9/19/07, bgoetzmann <[EMAIL PROTECTED]> wrote:
>
> Thank you James,
>
> I succeed to send email, using this URI:
>
> smtp://[EMAIL PROTECTED]
>
> I've seen that you can use of # to define a destination email by look at
> code source (otherwise it seems that the email [EMAIL PROTECTED] is used.
>
>
> Now I try to use my own MailComponent instance with the scheme "mail"; here
> the code:
>
>
> JndiContext context = new JndiContext();
>
> MailComponent mail = new MailComponent();
> context.bind("mail", mail);
>
> CamelContext camelContext = new DefaultCamelContext(context);
>
> camelContext.addRoutes(new RouteBuilder() {
>
>   public void configure() {
>     from("timer:myTimerEvent?fixedRate=true&delay=0&period=1000")
>     .setBody(Builder.constant("Salut
> !")).to("mail://[EMAIL PROTECTED]@www.com");
>   }
>
> });

In general that should all work fine; one complication with the Mail
component is that it supports a few different protocols; pop3, smtp
and so forth. So if you use, say, "smpt" instead of "mail" in the
above code (both the URL and the registration in JNDI) it should work
just fine.

e.g.

JndiContext context = new JndiContext();

MailComponent mail = new MailComponent();
context.bind("smtp", mail);

CamelContext camelContext = new DefaultCamelContext(context);

camelContext.addRoutes(new RouteBuilder() {

 public void configure() {
   from("timer:myTimerEvent?fixedRate=true&delay=0&period=1000")
   .setBody(Builder.constant("Salut
!")).to("smtp://[EMAIL PROTECTED]@www.com");
 }

});


BTW the use of JNDI or Spring ApplicationContext is an optional
feature to help you reuse a single registry for configuration; if you
prefer you can just register components and endpoints directly on the
CamelContext via addComponent/addSingletonEndpoint.

-- 
James
-------
http://macstrac.blogspot.com/

Reply via email to