IMAP Message in Java Mail is identified by it’s relative position number which starts from 1.
refer,
http://docs.oracle.com/javaee/1.4/api/javax/mail/Message.html#getMessageNumber()
Message number is a temporary details.
Is there a way to permanently uniquely identify a mail/message which accessing a mailbox via IMAP using Java Mail API which holds true across sessions ?
Look at the UIDFolder interface, which exposes the IMAP UID capability.