javamail: Setting custom flags on imap mail and searching for mails with custom flags
Asked Answered
A

1

8

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!

Aecium answered 14/2, 2012 at 14:3 Comment(0)
E
18
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));
Encarnacion answered 14/2, 2012 at 18:35 Comment(4)
How can we get the limit of custom mail flags per mailbox?Tally
Does it supported by exchange server?Tally
There's no standard way to get the limit on flags. I believe Exchange does support user flags.Encarnacion
I found it here, it seems that exchange does not support: serverfault.com/questions/115769/…, its permanent flag does not contain \*.Tally

© 2022 - 2024 — McMap. All rights reserved.