While working on a Java application yesterday, I ran into a situation where I needed to search my POP3 mailbox for unseen messages, i.e., email messages I haven't read yet. (I'm adding some "You've got mail" functionality to one of my automated robots.)
Jumping right to the solution, here's the complete source code for a JavaMail example class that demonstrates how to search for unseen (unread) email messages in a POP/POP3 mailbox: