Results 1 to 6 of 6

Thread: Get Emails through IMap

  1. #1
    Join Date
    May 2012
    Posts
    4

    Question Get Emails through IMap

    Good Afternoon,

    I'm needing to connect to a imap account to get all incoming messages, but when I try to use the ImapReceiver I can check the total messages in the account, but not get the messages.

    Following example used.

    1th
    Code:
    ImapMailReceiver receiver = new ImapMailReceiver("imaps://xxxx:yyyy@imap.gmail.com:993/INBOX");
    receiver.setShouldMarkMessagesAsRead(true);
    receiver.setShouldDeleteMessages(true);
    
    // When i call this method throw new exception  "NullPointerException"
    Message[] a = receiver.receive();
    Exception:

    Code:
    Exception in thread "main" javax.mail.MessagingException: A7 NO STORE attempt on READ-ONLY folder (Failure);
      nested exception is:
    	com.sun.mail.iap.CommandFailedException: A7 NO STORE attempt on READ-ONLY folder (Failure)
    	at com.sun.mail.imap.IMAPMessage.setFlags(IMAPMessage.java:905)
    	at javax.mail.Message.setFlag(Message.java:578)
    	at org.springframework.integration.mail.AbstractMailReceiver.setMessageFlags(AbstractMailReceiver.java:299)
    	at org.springframework.integration.mail.AbstractMailReceiver.postProcessFilteredMessages(AbstractMailReceiver.java:265)
    	at org.springframework.integration.mail.AbstractMailReceiver.receive(AbstractMailReceiver.java:254)
    	at org.springframework.integration.samples.mail.imapidle.GmailInboundImapIdleAdapterTestApp.main(GmailInboundImapIdleAdapterTestApp.java:41)
    Caused by: com.sun.mail.iap.CommandFailedException: A7 NO STORE attempt on READ-ONLY folder (Failure)
    	at com.sun.mail.iap.Protocol.handleResult(Protocol.java:351)
    	at com.sun.mail.imap.protocol.IMAPProtocol.storeFlags(IMAPProtocol.java:1589)
    	at com.sun.mail.imap.protocol.IMAPProtocol.storeFlags(IMAPProtocol.java:1574)
    	at com.sun.mail.imap.IMAPMessage.setFlags(IMAPMessage.java:901)
    	... 5 more
    Last edited by tiarebalbi; Feb 8th, 2013 at 05:13 AM. Reason: Posting Exception

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,037

    Default

    You need to show the exception (full stack trace).
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,037

    Default

    I suggest you change your gmail password - you had it in clear text above - I have edited it out.

    Looks like you hid it when you posted the same question on StackExchange.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  4. #4
    Join Date
    May 2012
    Posts
    4

    Default

    Sorry for that error,

    I edited the original post to insert the exception.

    Thanks!

  5. #5
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,037

    Default

    Why are you trying to use the ImapMailReceiver programmaticially that way (instead of configuring it normally)?

    There is a lot of stuff that the Spring Framework does to wire up and initialize these components. For example, afterPropertiesSet() changes the open mode for the inbox from READ_ONLY to READ_WRITE (which is the cause of your problem).

    So, either wire up the receiver using a Spring application context (XML or @Bean), or be sure to call afterPropertiesSet() after you (er) set the properties.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  6. #6
    Join Date
    May 2012
    Posts
    4

    Thumbs up

    Dear Gary Russell,

    I'm trying to understand before i implement in the project, but i'll check what you said for check if this error will happen again.

    Thanks for your help.

    Quote Originally Posted by Gary Russell View Post
    Why are you trying to use the ImapMailReceiver programmaticially that way (instead of configuring it normally)?

    There is a lot of stuff that the Spring Framework does to wire up and initialize these components. For example, afterPropertiesSet() changes the open mode for the inbox from READ_ONLY to READ_WRITE (which is the cause of your problem).

    So, either wire up the receiver using a Spring application context (XML or @Bean), or be sure to call afterPropertiesSet() after you (er) set the properties.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •