I managed to get a successful reply from the mail server (Gmail.com) using IMAP and vb.net with this code in this post
Now, I want to retrieve the number of E-mail messages from Inbox folder, how to do it?!
After you connect to the server, you'll issue a set of commands like this:
A001 LOGIN <username> <password> A002 SELECT INBOX
In response to the SELECT INBOX, the server will respond with a bunch of responses:
* OK [UIDVALIDITY 38] * 13 EXISTS * 0 RECENT A002 OK Inbox selected. ...
EXISTS response is the number of messages in the INBOX.