Message message = inbox.getMessage(messageNum);
boolean unread = !message.isSet(Flags.Flag.SEEN);
if (config.getMarkMessagesAsRead()) {
message.setFlag(Flag.SEEN, true);
}
<BUG>EmailMessage emailMessage = wrapMessage(message, true);
</BUG>
if (!config.getMarkMessagesAsRead()) {
emailMessage.setUnread(unread);
}

Message message = inbox.getMessage(messageNum);
boolean unread = !message.isSet(Flags.Flag.SEEN);
if (config.getMarkMessagesAsRead()) {
message.setFlag(Flag.SEEN, true);
}
EmailMessage emailMessage = wrapMessage(message, true, session);
if (!config.getMarkMessagesAsRead()) {
emailMessage.setUnread(unread);
}
