Receiving multipart mail with POP3

Please post support and help requests here.
Posts: 1
Joined: 19 Jun 2007, 12:38

Receiving multipart mail with POP3

Postby jasonc » 19 Jun 2007, 13:06

I'm new to POCO. I have successfully used the POCO::Net namespace in sending mails with attachments (SMTP). However, I am struggling to create an implementation that receives multi-part mail and mail with attachments (POP3).

Is there any tutorial or sample code out there that demonstrates how multi-part mail / mails with attachments can be read from a POP3 server. I have consulted the on-line documentation but I am none the wiser for it.


Posts: 1268
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Receiving multipart mail with POP3

Postby guenter » 20 Jun 2007, 16:09

To receive mail messages from a POP3 server, you use the POP3ClientSession class.
Usage is basically as follows:

* create an instance of POP3ClientSession, specifying the hostname/ipaddress of the POP3 server in the constructor.
* call login(), specifying your POP3 username and password.
* call messageCount() to obtain the number of messages on the server
* call listMessages() to get a list of all messages IDs (and message sizes) from the server.
* call retrieveMessage() to read a message from the server. You can do that in a loop, iterating over all message IDs obtained via listMessages(). There are three variants of this member function. If you want to receive a multipart message, use the one that takes three arguments - id, MailMessage reference and PartHandler reference. The PartHandler's handlePart() virtual member function (which you must implement in your own subclass of PartHandler) will be called for every MIME part in the mail message.
* call close() to close the connection to the POP3 server.

Return to “Support”

Who is online

Users browsing this forum: No registered users and 2 guests