Announcement Announcement Module
Collapse
No announcement yet.
Get Emails through IMap Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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:[email protected]: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, 06:13 AM. Reason: Posting Exception

  • #2
    You need to show the exception (full stack trace).

    Comment


    • #3
      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.

      Comment


      • #4
        Sorry for that error,

        I edited the original post to insert the exception.

        Thanks!

        Comment


        • #5
          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.

          Comment


          • #6
            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.

            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.

            Comment

            Working...
            X