Search code examples
javaemailjakarta-mailread-unread

java.mail mark message as unread


I am building an automatic mail processor application and I am parsing the emails one by one. If parsing one of the messages fails I would like to mark that message as unread? How do I mark a message as unread please?

Thank you


Solution

  • messageObject.setFlag(Flags.Flag.SEEN, false);

    The first parameter is the Flag, the second one it's if you want to negate that flag, so a Seen with flase is UNSEEN.

    PS: You need to use imap, you can't do this with pop3