public MessagesWrapper markAsRead(List<Message> messagez) throws IOException, MessagingException { if (folder.isOpen() && folder.getMode() != Folder.READ_WRITE) { folder.close(true); } if (!folder.isOpen()) { folder.open(Folder.READ_WRITE); } for (Message message : messagez) { message.setFlag(Flags.Flag.SEEN, true); } logger.info("Marked email(s) as read : " + messagez.size()); return this; }
public void close() throws MessagingException { folder.close(true); }