Gmail provides an atom feed for your inbox.
Just go to https://mail.google.com/mail/feed/atom and login using basic HTTP auth to get your unread mail in a nice parseable format.
The same isn't available for hotmail, but someone wrote a PHP wrapper class (that I haven't tested) here http://www.palmeteo.com/hotmailrss/
Here is the source if you do not trust that site with your hotmail credentials http://www.palmeteo.com/hotmailrss/src/