Hello Bilgin

I read SSL and Enable POP and IMAP in my gmail account.
I have written code for polling mail but not getting any result. It
must be my mistake somewhere.

Please help me to correct my code. I want to read mails to complete my project.

public class MailPoller {

    public static void main(String[] args) {
        try {
            CamelContext myCamelContext = new DefaultCamelContext();
            RouteBuilder routeBuilder = new RouteBuilder(myCamelContext) {

                @Override
                public void configure() throws Exception {

from("imaps://imap.gmail.com?username=myusern...@gmail.com&password=mypassword"
                            + "&delete=false&unseen=true").to("log:newmail");
                }
            };

            myCamelContext.start();

        } catch (Exception ex) {
            Logger.getLogger(MailPoller.class.getName()).log(Level.SEVERE,
null, ex);
        }
    }
}

On 11/11/11, Bilgin Ibryam <bibr...@gmail.com> wrote:
> Hi Ketan,
>
> Please read (again) the SSL section of mail component documentation from
> Camel website and check the example there. Then you have to enable pop for
> your gmail account in the settings.
>
> Finally the rout should look like something like this:
>
> pop3s://pop.gmail.com?username=....
>
> or
>
> imaps://imap.gmail.com?username=...
>
> notice the S in the schemas
>
>
> HTH
> Bilgin
>
>
> On Thu, Nov 10, 2011 at 3:22 PM, Ketan Barapatre
> <ketanbarapa...@gmail.com>wrote:
>
>> Hello All,
>>
>> To poll the mail. I tried following code
>>
>> CamelContext myCamelContext = new DefaultCamelContext();
>>  //final String url = "imap://
>> imap.gmail.com?username=myusern...@gmail.com&password=mypassword";
>>  //final String url = "smtp://
>> smtp.gmail.com:465?password=mypassword&username=myusern...@gmail.com";
>>  final String url = "pop3://myusern...@gmail.com?password=mypassword";
>> Endpoint endpoint = myCamelContext.getEndpoint(url);
>>  System.out.println(" endpoint " + endpoint);
>>
>> RouteBuilder routeBuilder = new RouteBuilder(myCamelContext) {
>>  @Override
>> public void configure() throws Exception {
>>    from(url).process(new MyMailProcessor());
>>  }
>> };
>>
>> myCamelContext.addRoutes(routeBuilder);
>>  myCamelContext.start();
>> MyMailProcessor.java
>>
>> public class MyMailProcessor implements Processor {
>>
>>     public void process(Exchange exchng) throws Exception {
>> System.out.println("" + exchng);
>>     }
>> }
>>
>> As i understand when message is read from my Inbox *process* method of
>> MyMailProcessor executes.
>>
>> Please correct me if i'm wrong. I am very new to this.
>>
>> I am using camel-mail v2.8.2 and NetBeans 7 on Win XP.
>>
>>
>>
>


-- 

Regards
Ketan Barapatre

Reply via email to