I’ve been working lately on a couple of programs that need to access IMAP e-mail accounts. First, if you need to do this in .Net, MailSystem.NET is a good open source library. I’ve had a few problems with parts of it, but the basic functionality is solid.
Figuring out how to test and troubleshoot a program that’s reading messages and moving them around in an e-mail account can be a little tricky. First, it’s useful to know how to do IMAP stuff at a low level. This page has a great overview of how to access an IMAP account directly over telnet. And, if you want to copy the contents of one IMAP account to another, so you can have an account to test against, then imapsync is a very good thing.
One other random helpful hint: I’m working with both GMail and 1&1 IMAP accounts. I’ve found that there are some unexpected differences between them. For instance, GMail generally returns a message containing the word “Success” when a command is successful. 1&1 returns a completely different message, so you need to be careful about what you’re looking for in a response string.