The best way to do this, is write a pop3 protocol parsing functions, this is hard to to, but the result is a class of functions that can be parsed in every plataform, without or with imap module compiled.
The easy way to do this is using imap functions, but with mime mails that contains txt+html text versions plus attachment, imap cannot retrive bodies that have nested mime contents.
For any questions that concernes about this function, feel free to contact me.
Good luck.
Rodrigo Spivak Cavalcanti