I couldn’t find all that much information about IMAP on the web, other than the RFC3501.
The IMAP protocol document is absoutely key to understanding the commands available, but let me skip attempting to explain and just lead by example where I can point out the common gotchas I ran into.