javamail:在imap邮件上设置自定义标志,并使用自定义标志搜索邮件 [英] javamail: Setting custom flags on imap mail and searching for mails with custom flags
问题描述
是否可以使用Java邮件在IMAP邮件消息上设置自定义标志,而不会覆盖现有标记?例如,我需要在处理的消息上设置一个标记处理,而不会将其状态更改为SEEN / DELETED,或者不影响这个已处理标志的邮件客户端。
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".
谢谢!
推荐答案
Flags processedFlag = new Flags("processed");
folder.setFlags(msgs, processedFlag, true);
// or
msg.setFlags(processedFlag, true);
并非所有IMAP服务器都将支持这些用户标志,但大多数会。要找到没有此标志的消息:
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));
这篇关于javamail:在imap邮件上设置自定义标志,并使用自定义标志搜索邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!