Hi there.
I have a bit trouble with JavaMail 1.4.1. I think, I use it in the wrong way, but I get no clue what I'm doing wrong.
I would like to delete some messages in an IMAP folder. This is the source code for it:
openFolder(folder, Folder.READ_WRITE);
Message[] msgs = folder.search(term);
Flags fl = new Flags();
fl.add(Flags.Flag.DELETED);
inbox.setFlags(msgs, fl, true);
inbox.expunge(msgs);
I removed some code of the error checking just for simplicity. Ahh.. and the connection to the IMAP server is open.
When activating the debug mode, I get following output:
A6 SELECT inbox
* 268 EXISTS
* 1 RECENT
* FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)
* OK [PERMANENTFLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)] Permanent flags
* OK [UNSEEN 266] Is the first unseen message
* OK [UIDVALIDITY 5109] UIDVALIDITY value
A6 OK [READ-WRITE] SELECT completed.
A7 SEARCH FROM myFancyIMAPServer ALL
* SEARCH 266 267 268
A7 OK SEARCH completed.
A8 STORE 266:268 +FLAGS (\Deleted)
* 266 FETCH (FLAGS (\Deleted))
* 267 FETCH (FLAGS (\Seen \Deleted))
* 268 FETCH (FLAGS (\Deleted \Recent))
A8 OK STORE completed.
A9 FETCH 266:268 (UID)
* 266 FETCH (UID 4649)
* 267 FETCH (UID 4650)
* 268 FETCH (UID 4659)
A9 OK FETCH completed.
A10 UID EXPUNGE -1,-1,-1
A10 BAD Protocol Error: "Specified message set is invalid".
IMAP DEBUG: IMAPProtocol noop
A11 NOOP
A11 OK NOOP completed.
I just inserted some whitespace for a better readability. The striking thing is that the expunge command gets some '-1' values for the uids which obviously don't exist. But a just mentioned before I don't know where the error is located. Maybe you could help me?
thanks.
Edited by: bravedreamer1 on Mar 5, 2009 2:31 AM
I tried also to use the expunge functionality with the close command of the folder. In this case it works. But here, all mails which are marked as DELETED are expunged. And that is not really wanted.