Fundamentals of the JavaMail API[
^]
unfortunately only available as PDF, pretty great tutorial.
Your Problem:
You are receiving unread messages - but not the ones that have already been seen? That would need you to set the
Flag.SEEN
on the messages when you display them.
Normally one receives a complete Array of
Message
objects of the corresponding folder.
You're probably filtering that Array for a the flag "
Flag.SEEN
" to be
not set.