Saving a Mail Message to a File
If you attempt to save a mail message to a file using the RWStreamCoupler mechanism, use the pop3StreamFilter global function. You can find its declaration in the pop3.h header file as the filter of the RWStreamCoupler::operator() method. This filter indicates an end-of-data (mail) condition on a POP3 input stream, as shown in the following example.
Example 22 – Saving a mail message to a file
RWPop3DataReply reply;
reply = client.retr(1); // retrieve the first message
 
RWPortalIStream istr(reply.portal()); // construct an input stream
 
ofstream ostr("save.me"); // construct an output stream in save.me
 
RWStreamCoupler couple;
couple(istr, ostr, pop3StreamFilter);