Saqib Ali
Saqib Ali

Reputation: 4448

Maintain IMAP message state information (imap flags) when using Javamail

We have a java app built by third party that opens a read/write IMAP connections, and retrieves certain messages. However it also marks them as "read". I am guessing this is due to fact that the app opens a read/write connection. Is there a way we can prevent this app from updating the "read (seen)" imap flag? Maybe a parameter we can set when opening the connection to the IMAP?

Upvotes: 1

Views: 1309

Answers (2)

Bill Shannon
Bill Shannon

Reputation: 29971

Open the Folder read-only instead of read/write.

Upvotes: 3

Cristian Meneses
Cristian Meneses

Reputation: 4041

You can do this for a single message:

folder.setFlags(new Message[] {message}, new Flags(Flags.Flag.SEEN), false);

or for a list of messages:

folder.setFlags(messageList, new Flags(Flags.Flag.SEEN), false);

where false stands for UNREAD.

Upvotes: -1

Related Questions