To access a mailbox you can use to different protocols:
POP3 and IMAP.
If you don't retrieve the email and store it in a database, the only usable protocol is IMAP. With this protocol, the mail stays in the mailbox.
Please use a search engine or a good book for more information about these protocols.