Originally posted by Seetesh Hindlekar: Message message = folder.getMessages(); message[i].getMessageNumber();
Sorry, but this is the wrong answer. This does not give you the message's unique ID, it just gives you the number of the message in the folder. If you look later and messages have been deleted / added to the folder, the numbers will have changed.
You can get the Message-ID header using getHeader:
Note that this is not 100% reliable; I've tried to use it in a real world situation, and not all mail servers add a Message-ID header to the message, even though the SMTP specification says it is required.
So don't count on it that all mail messages have a unique ID.