javamail: Setting custom flags on imap mail and se

2019-02-10 00:55发布

Is it possible to set custom flags on IMAP mail messages using java mail without overwriting existing flags? Eg, I need to set a flag "processed" on processed messages without changing its state to SEEN / DELETED or without mail clients interfering with this "processed" flag.

Then I need to find all mail that doesn't have the "processed" flag and process them after which they are also flagged as "processed".

Thanks!

1条回答
Bombasti
2楼-- · 2019-02-10 01:09
Flags processedFlag = new Flags("processed");
folder.setFlags(msgs, processedFlag, true);
// or
msg.setFlags(processedFlag, true);

Not all IMAP servers will support these "user flags", but most will. To find messages without this flag:

Message[] msgs = folder.search(new FlagTerm(processedFlag, false));
查看更多
登录 后发表回答