• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaMail IMAP And GMail Unread Messages

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've spent quite a bit of time this evening messing around the JavaMail's IMAP support and GMail. The problem I am having is trying to simply check for new messages. It would seem that for whatever reason GMail doesn't implement the Flags.Flag.RECENT flag. The only way I can seem to reliably determine if there is a new message after authenticating to the server is by checking each messages system flags like so:



Most of the time the user flags are also zero in length, but not all the time. So I can't rely on that. While this works the problem with it is that I am really bad about archiving my email. So I have 2000+ messages under the "Inbox" label. It takes a long time for JavaMail to go through all 2000+ messages and check the flags. Does anyone know of a better way, upon initial authentication, to get just messages that are unread?
[ May 11, 2008: Message edited by: Gregg Bolinger ]
 
Scott Selikoff
author
Saloon Keeper
Posts: 4010
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not really but I can attest to the fact that GMail is 'funny' about recent mail. Every once in awhile GMail will have trouble syncing and start downloading all messages over again. One thing I suggest trying is you can access your mail by putting the prefix "recent:" as part of your account login. See if this helps: https://mail.google.com/support/bin/answer.py?answer=47948

If I understand it correctly, without the "recent:" flag, GMail automates the synchronization and causes problems similar to what you're describing. With this flag, the clients handle synchronization. But as with anything useful, there is a catch: with the recent flag, the client also downloads all sent mail from you. I have a filter on my computer to move sent mail from me to the "Sent" folder, of course this ends up with duplicate messages in my sent folder (one I sent from the client, and the one downloaded from GMail).
[ May 11, 2008: Message edited by: Scott Selikoff ]
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Scott. I use Thunderbird for accessing GMail via IMAP and have never noticed this issue. With this JavaMail stuff I am leaning more towards a notifier than a full fledged client. It looks like the issue you linked to is a POP issue, not IMAP, but I might give it a shot anyway.

Update: doesn't work. Authentication fails.
[ May 11, 2008: Message edited by: Gregg Bolinger ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic