Your best bet is using the pop3 or imap protocols.
- Examples of pop3 in Visual Basic
- A GNU library for C providing a Pop3 API
Equivalent libraries for IMAP will also be available. Your other alternative is to be a "fake browser" which logs in and scans the page for a specific HTML element such as "inbox(3)" but that seems messy when they provide proper protocols.
Or, my favorite approach is the Python libgmail library which can be found here. Here is a little example in Python:
ga = libgmail.GmailAccount("[email protected]", "mymailismypass")
ga.login()
folder = ga.getMessagesByFolder('inbox')
for thread in folder:
print thread.id, len(thread), thread.subject
for msg in thread:
print " ", msg.id, msg.number, msg.subject
print msg.source
But the code can become unstable when Google change some of their GMail setup.