Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Internet Protocols Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

6.6 Mail Retrieval: Using the POP3 Client

Example 24 shows basic POP3 command access. After making a successful connection to a POP3 server and completing login transactions, the program checks for messages in a mail box. If it finds any messages, it gets the first message in the mail drop and displays it on the screen.


Servers and files shown in the code might not exist and are included as examples only.

Example 24: Using the POP3 client

//1

Constructs an RWPop3Client object. The object is set to an unconnected state that is ready to use the connect() method of RWPop3Client to establish a connection with a POP3 server. When the object goes out of scope, disconnection from the server is automatic.

//2

Establishes a connection with a POP3 server.

//3

Performs the USER protocol command.

//4

Performs the PASS protocol command.

//5

Performs the STAT protocol command.

//6

Gets the total number of pending messages in the mail drop using the getMessageCount() method of class RWPop3StatReply.

//7

Performs the RETR protocol command and immediately redeems the result as the RWPop3DataReply object dataReply. dataReply contains a socket portal to complete the data portion of the protocol transfer.

//8

Checks that the data reply is +OK. A successful reply from the retr() method is normally +OK, which indicates that the data connection has been opened.

//9

Gets the data socket portal from the dataReply object to retrieve data from the underlying socket.

//10

Creates an RWPortalIStream object istr from the socket portal in //9. The object istr becomes the data source.

//11

Reads one line of the mail data at a time.

//12

Removes the line feed at the end of the line.

//13

Reads message data until a period is in a line by itself, which indicates the end of a mail message.

//14

This catch clause catches all POP3 package, Networking package, and Threads Module exceptions that can be thrown from within the try block because all Rogue Wave exceptions are derived from RWxmsg.

This example demonstrates one method of redeeming an RWTIOUResult object. For other methods, see Section 2.4, "Multithreading and IOUs," and Section 4.7, "File Retrieval: Using the FTP Agent (Part II),"



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.