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

后端 未结 1 1341
清歌不尽
清歌不尽 2021-01-02 16:42

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 wit

1条回答
  •  离开以前
    2021-01-02 17:17

    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));
    

    0 讨论(0)
提交回复
热议问题