Hacked together some code that uses JavaMail to connect to IMAP. Not tested yet. Also might need some cleanup.