It looks like you can have max 20 connections to your IMAP server at the same time. (At least that's how I interpret the Exception). Check if you use the same Session during your work with your folders, instead of creating new Sessions...