Thanx Gigi you saved my day,
let me complete the answer with what I have done and maybe somebody would find it useful.
STORE <<startScope>>:<<endScope>> +FLAGS (\Delete)
is the real solution in my case. I am now using something like this:
private Object storeDeletion(IMAPProtocol protocol, int startID, int endID)
throws ProtocolException{
String args = Integer.toString(startID) + ":"
+ Integer.toString(endID)
+ " +FLAGS" + " (\\Deleted)";
Response[] r = protocol.command("STORE " + args, null);
int notDeleted = 0;
for (Response res : r) {
// do something here with each response, but avoid last one (summary response)
}
// dispatch remaining untagged responses
protocol.notifyResponseHandlers(r);
protocol.handleResult(r[r.length-1]);
return "" + (r.length - notDeleted - 1);
}
If you don't want to check all the responses you can use +FLAGS.SILENT
instead of +FLAGS
. notDeleted is incremented inside the for loop for all problematic mails that couldn't be marked as deleted for some reason.