* @param messageNumber the message number ex:{@code gmailMessage.getMessageNumber()}
* @throws GmailException if unable to mark {@link GmailMessage} as read
*/
public void markAsRead(int messageNumber) {
if (messageNumber <= 0) {
throw new GmailException("ImapGmailClient invalid "
+ "GmailMessage number");
}
Folder folder = null;
try {
final Store store = openGmailStore();
folder = getFolder(this.srcFolder, store);
folder.open(Folder.READ_WRITE);
Message message = folder.getMessage(messageNumber);
if (!message.isSet(Flags.Flag.SEEN)) {
message.setFlag(Flags.Flag.SEEN, true);
}
} catch (Exception e) {
throw new GmailException("ImapGmailClient failed marking"
+ " GmailMessage as read : " + messageNumber, e);
} finally {
closeFolder(folder);
}
}