Search code examples
javaspring-bootkotlinapache-camelspring-camel

How to read a gmail with Apache Camel


i am trying to read a gmail using the routebuilder() of apache camel.

@Component
class ReadEmailRouteBuilder(var stockLocationProperty: 
StockLocationProperty) : RouteBuilder() {

    override fun configure() {
    //TODO
    }
}

This is the start i have to use and i have tried many ways but it never worked, can someone help me?


Solution

  • Dependending on what protocol you are using (IMAP for instance), the answer could look like :

    from("imaps://imap.gmail.com?username={{gmail.username}}&password={{gmail.password}}&delete=false&unseen=true&consumer.delay=60000")
        .process(new MailAttachmentProcessor())
        .to("file://gmails");