How can I retrieve a list of UIDs from the mail server for POP3 with JavaMail?

John Zukowski

Use the fetch() method to prefetch information. If the FetchProfile contains UIDFolder.FetchProfileItem.UID, POP3 UIDs for all messages in the folder are fetched using the POP3 UIDL command. If the FetchProfile contains FetchProfile.Item.ENVELOPE, the headers and size of all messages are fetched using the POP3 TOP and LIST commands.

See the sundocs for the Pop3Folder for more information. [javamail-1.2/docs/sundocs/com/sun/mail/pop3/POP3Folder.html#fetch]. These are provided with the JavaMail 1.2 release.