Java mail IMAP list example - List all the email addresses in an IMAP mailbox
Java Mail (JavaMail) IMAP FAQ: Can you show me how to get a list of all the email addresses in an IMAP mailbox using the Java Mail API (JavaMail API)?
Sure. Here's the source code for a Java mail (JavaMail) program that extracts all of the "from" fields out of a specified mailbox. This works for both POP3 and IMAP mailboxes.
Before going to the code, note the cool use of a TreeSet
(java.util.TreeSet
) in this example. Based on our offline discussion, you mentioned that you really want is this: