Class POP3Client() Professional

Class function of the POP3Client class.

Description

Instances of the POP3Client class are used to access a POP3 server using the Post Office Protocol Version 3. This communication protocol is used to retrieve e-mail messages from a mail server.

A POP3Client connects via the TCP/IP network protocol to an e-mail server and then negotiates the parameters for retrieving messages. This so-called POP3 handshake is performed when the method :connect(). is executed.

By default, e-mails are transferred unencrypted as human-readable data. However, the POP3Client class also supports establishing connections where all communication is encrypted via a Secure Socket Layer (SSL). See the method :new() for more details on setting up secure connections.

Class methods
:new()
Creates an instance of the POP3Client class.
Methods for retrieving e-mails
:connect()
Connects to the POP3 server.
:isConnected()
Checks if a connection is established
:deleteMessage()
Deletes an e-mail message on the POP3 server.
:disconnect()
Disconnects from the POP3 server.
:getMessage()
Retrieves an e-mail message from the POP3 server.
:getMessageString()
Retrieves an e-mail message from the POP3 server as a character string.
:getNumberOfNewMessages()
Returns the number of messages available in the mail account.
:undeleteMessage()
Unmark all messages which are marked as deleted.
:getTotalMessageSize()
Retrieve the number of bytes on the POP3 server.
:getMessageIdentifier()
Retrieves the identifiers and message numbers of all messages on the POP3 server.
:getMessageSize()
Retrieves the sizes and message numbers of all messages on the POP3 server.
:setConnectionSecurity()
Configures secure communication with the server.
:setTimeout()
Set the timeout value for communication with the POP3 server.
:getTimeout()
Get the timeout value for communication with the POP3 server.
:getMessageHeader()
Return the Header of a Message.
:getMessageHeaderString()
Return the Header of a Message.
:setProgressBlock()
Set a code block for progress evaluation
:getLastError()
Returns the numeric value of the last error
Examples
Retrieving e-mails via SSL
// The example explains how to access a POP3 server 
// for e-mail retrieval. The pending e-mails are 
// retrieved from a mailbox in the FOR..NEXT loop. 
// Limited e-mail data is then displayed, i.e. the 
// e-mail of the sender ("From:" header) and the 
// subject line ("Subject:" header) are listed. 
// Refer to the classes MIMEContent(), MailAddress() 
// and MIMEMessage() for additional examples. 

#pragma library("asinet10.lib") 

PROCEDURE Main 
   LOCAL oLog 
   LOCAL oPOP3, i, nCount 
   LOCAL oMail, oSender, cSubject 

   oLog := LogWriter():new() 

   // Connect to the Windows Live POP3 server. 
   // Port number 995 implies a secure SSL 
   // connection. Use standard port 110 for 
   // unencrypted communication and for servers 
   // which do not support SSL. 
   oPop3 := POP3Client():new( "pop3.live.com", 995         , ; 
                              "panthera.roseus@hotmail.com", ; 
                              "0924LargeCat"               , ; 
                              oLog, 2 ) 
   IF .NOT. oPOP3:connect() 
      ? "Unable to establish connection" 
      QUIT 
   ENDIF 

   nCount := oPOP3:getNumberOfNewMessages() 

   FOR i := 1 TO nCount 
      // Obtain MIMEMessage object for e-mail 
      oMail := oPOP3:getMessage( i ) 

      // Obtain MailAddress object of sender 
      oSender := oMail:getFrom() 
      IF .NOT. Empty( oSender ) 
         ? "From:", oSender:getString() 
      ELSE 
         ? "Unknown sender" 
      ENDIF 

      // Subject line of e-mail 
      cSubject := oMail:getSubject() 
      IF .NOT. Empty( cSubject ) 
         ? "Subject:", cSubject 
      ELSE 
         ? "Unknown subject" 
      ENDIF 

   NEXT 

   oPOP3:disconnect() 
RETURN 

/* 
 * User-defined class for log-data processing 
 */ 
CLASS LogWriter 
   EXPORTED: 
   INLINE METHOD write( cLogData ) 
      ? cLogData 
   RETURN 
ENDCLASS 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.