Error Retrieving mails using IMAP
843830Aug 1 2007 — edited Aug 23 2007Hi
I am trying to retrieve mails from a WorkgroupMail v7.6 using IMAP. If I use POP3 to retrieve the message, I can fetch the message successfully. However when I use IMAP to fetch the same message, I get the following error when I try to get the content-type as:
maiMessage.getContentType();
-----------------------//Exception Start
javax.mail.FolderClosedException: * BYE Connection down
at com.sun.mail.imap.IMAPMessage.loadBODYSTRUCTURE(IMAPMessage.java:1105)
at com.sun.mail.imap.IMAPMessage.getContentType(IMAPMessage.java:339)
-------------------------//Exception End
I have gone through the JavaMail FAQs and as suggested, I used the MimeMessage copy constructor to make a copy of the entire message. This way I am able to parse the message. However, now when I try to update the message status, I run into the following error:
-----------------------//Exception Start
javax.mail.FolderClosedException: * BYE Connection down
at com.sun.mail.imap.IMAPMessage.setFlags(IMAPMessage.java:751)
at javax.mail.Message.setFlag(Message.java:541)
-----------------------//Exception End
I have turned on Session Debugging and the output is below:
GLOBAL_SCOPE setDebug: JavaMail version 1.3
GLOBAL_SCOPE DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]
GLOBAL_SCOPE * OK Softalk IMAP Server ready
GLOBAL_SCOPE A0 CAPABILITY
GLOBAL_SCOPE * CAPABILITY IMAP4rev1
GLOBAL_SCOPE A0 OK CAPABILITY completed
GLOBAL_SCOPE A1 LOGIN sterling password
GLOBAL_SCOPE A1 OK LOGIN completed
GLOBAL_SCOPE A2 LIST "" inbox
GLOBAL_SCOPE * LIST () "/" "Inbox"
GLOBAL_SCOPE A2 OK LIST completed
GLOBAL_SCOPE DEBUG: connection available -- size: 1
GLOBAL_SCOPE A3 SELECT Inbox
GLOBAL_SCOPE * 1 EXISTS
GLOBAL_SCOPE * 1 RECENT
* OK [UIDVALIDITY 1184897694]
* FLAGS (\Deleted \Seen)
A3 OK [READ-WRITE] SELECT completed
GLOBAL_SCOPE TotalMessages =1
GLOBAL_SCOPE A4 FETCH 1 (FLAGS)
GLOBAL_SCOPE * 1 FETCH (FLAGS () UID 8)
GLOBAL_SCOPE A4 OK FETCH completed
GLOBAL_SCOPE A5 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE)
GLOBAL_SCOPE * 1 FETCH (ENVELOPE ("Mon, 30 Jul 2007 14:10:05 +0100" "Debug test" (("Partner" NIL "partner" "sterling.demo")) (("Partner" NIL "partner" "sterling.demo")) (("Partner" NIL "partner" "sterling.demo")) (("" NIL "sterling" "sterling.demo")) NIL NIL NIL "<46ADE32D.5030202@sterling.demo>") INTERNALDATE "30-Jul-2007 14:10:05 +0100" RFC822.SIZE 1074 UID 8)
GLOBAL_SCOPE A5 OK FETCH completed
GLOBAL_SCOPE A6 FETCH 1 (BODY[])
GLOBAL_SCOPE * 1 FETCH (BODY[] {1074}
GLOBAL_SCOPE Received: from 127.0.0.1 for sterling@sterling.demo; Mon, 30 Jul 2007 14:10:05 +0100
Message-ID: <46ADE32D.5030202@sterling.demo>
Date: Mon, 30 Jul 2007 14:10:05 +0100
From: Partner <partner@sterling.demo>
Reply-To: partner@sterling.demo
Organization: Sterling Demo
User-Agent: Thunderbird 2.0.0.5 (Windows/20070716)
MIME-Version: 1.0
To: sterling@sterling.demo
Subject: Debug test
Content-Type: multipart/mixed;
boundary="------------030700000909090508060600"
This is a multi-part message in MIME format.
--------------030700000909090508060600
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
This is to debug the IMAP adaptor. Adding an attachment too.
--------------030700000909090508060600
Content-Type: text/plain;
name="MessageXML.txt"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="MessageXML.txt"
PERvY3VtZW50Pg0KCTxUeXBlPlRFU1Q8L1R5cGU+DQoJPE1lc3NhZ2U+VGhpcyBpcyBhIHRl
c3QgbWVzc2FnZTwvTWVzc2FnZT4NCjwvRG9jdW1lbnQ+
--------------030700000909090508060600-- UID 8)
A6 OK FETCH completed
GLOBAL_SCOPE [JDBCOutputStream] baos_init_size: 16384
GLOBAL_SCOPE A7 STORE 1 +FLAGS (\Seen)
GLOBAL_SCOPE javax.mail.FolderClosedException: * BYE Connection down
GLOBAL_SCOPE at com.sun.mail.imap.IMAPMessage.setFlags(IMAPMessage.java:751)
GLOBAL_SCOPE at javax.mail.Message.setFlag(Message.java:541)
I feel its an issue with the server's implementation of IMAP, like the FAQs have mentioned. But I would be for any help in identifying the issue.
Regards
Darchana