Class POP3Client() Professional
Class function of the POP3Client class.
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.
// 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
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.