![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Demo program for the [[http://mbed.org/users/hlipka/libraries/pop3|pop3 library]].
Dependencies: mbed TcpLineStream NetServicesMin pop3 DNSResolver
Diff: main.cpp
- Revision:
- 0:4a32b2fce260
diff -r 000000000000 -r 4a32b2fce260 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Apr 11 20:35:59 2012 +0000 @@ -0,0 +1,46 @@ +#include "EthernetNetIf.h" + +#include "mbed.h" + +#include "pop3.h" + +main() +{ + EthernetNetIf eth; + EthernetErr ethErr; + printf("Setting up...\n"); + do { + ethErr = eth.setup(); + if (ethErr) printf("waiting for network...\n", ethErr); + } while (ethErr != ETH_OK); + + Pop3 *p3=new Pop3("mail.server","mail.user","mail.password"); + + bool r=p3->init(); + + printf("init ok=%i\n",r); + + if(r) + { + list<string> *ids=p3->getMessages(); + list<string>::iterator it; + for ( it=ids->begin() ; it != ids->end(); it++ ) + { + printf("id=%s\n",(*it).c_str()); + + Pop3Message *msg=p3->getMessage(*it); + if (NULL==msg) + continue; + printf("from %s\n",msg->from.c_str()); + printf("subj %s\n",msg->subject.c_str()); + + p3->deleteMessage(*it); + + delete msg; + + } + delete ids; + } + p3->close(); + delete p3; +} \ No newline at end of file