POP3SecureSocket

From Xojo Documentation

Revision as of 18:56, 19 November 2009 by WikiSysop (talk) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Description

Used to retrieve messages on a POP3 mail server using SSL or TLS encryption.


Super Class

SSLSocket

Events

Name Parameters Description
ConnectionEstablished Occurs when a connection has been established.
Disconnected Occurs when the connection has been terminated.
ListReceived List as String Executes when the ListMessages method is called.

The List parameter contains the message listing.

LoginSuccessful Executes when the login process initiated by calling the Connect method is complete.
MessageCount Count as Integer Executes when the mail server replies to a CountMessages call and contains the number of messages in the mailbox.
MessageDeleted Index as Integer Executes when the mail server replies to a DeleteMessage call and contains the index number of the deleted message.
MessageReceived Index as Integer,

Message as emailMessage

Executes when a message has been received from the mail server, in response to a call to RetrieveMessage.

Index contains the index number of the retrieved message and the message contents is in Message.

RollbackSuccessful Executes in response to a call to RollbackServer and indicates that the state of the mailbox has been reset.
ServerAvailable Executes when the mail server has replied to a call to CheckServerConnection and indicates that the mail server has replied to the call.
ServerError ErrorCode as Integer,

ErrorMessage as String, MessageID as Integer

Executes when a protocol-related error occurs.

The error codes are as follows: 0 - Unknown Error Message 1 - Incorrect Password 2 - IncorrectUsername 3 - Delete Message Failed 4 - List Messages Failed 5 - Retrieve Lines Failed 6 - Retrieve Message Failed

TopLinesReceived Index as Integer,

Data as EmailMessage

Executes in response to a call to RetrieveLines.

Index contains the index number of the partial message being retrieved and Data contains the requested lines of the message.


Properties

Name Type Description
EncryptPassword Boolean If True, the password is encrypted when being sent to the mail server.
Password String The password to use for security when connecting to the mail server.
Username String The username to use for authentication when connecting to the mail server.


Methods

Name Parameters Description
CheckServerConnection Sends a "NOOP" command to the mail server.

This is simply a command that asks the server to reply. This can be useful to check that the mail server is still responding and also tells the mail server that you are still connected if there has been no activity for a long period of time.

Connect Connects to the mail server and logs in with the Username and Password.
CountMessages Asks the server for the number of messages in the mailbox.

CountMessages triggers the MessageCount event.

DeleteMessage Index as Integer Tells the mail server to delete the specified message.
DisconnectFromServer Disconnects from the mail server.

This sends a "QUIT" command to the mail server and waits for it to close the connection.

ListMessages [Index as Integer] Requests a message listing.

ListMessages triggers the ListReceived event. The list consists of the message index and the size of the message. If no index is passed, it gets the entire list from the server. If a specific index is passed, it will return just the index message and size of the message.

RetrieveLines Index as Integer,

LineCount as Integer

Returns the specified number of lines of a message.

The mail server will return the first LineCount of lines that exist in the message you are requesting via the Index parameter. If LineCount is zero, then the mail server returns only the headers for the message.

RetrieveMessage Index as Integer Reads the entire message specified by Index.
RollbackServer Resets the mail server to the state that it was when you logged in.

RollbackServer can be used to Undo deletions that occur by accident. The changes aren't committed until the connection is closed. RollbackServer will roll back changes that have not yet been committed.

SendServerCommand Command as String Sends the command specified by Command to the mail server.

SendServerCommand is useful when you need to send a command that REALbasic doesn't yet support.


Notes

The POP3SecureSocket class is identical to the POP3Socket class, except that it is derived from the SSLSocket class instead of the TCPSocket class. This enables you to send secure email by setting the Secure property of the SSLSocket class.

If you use a constructor of a subclass of POP3SecureSocket, you must call the Super class's constructor in your subclass's constructor. The subclass will not work unless this is done.


Examples

The following code in the MessageReceived event handler places the body of an email message in a TextArea.

Sub MessageReceived(ID as Integer, email as emailMessage)
Dim s as String
 s=email.bodyHTML
If s="" then
  s=email.bodyPlainText
 end
TextArea1.text=s


See Also

EmailMessage, HTTPSocket, POP3Socket, SMTPSecureSocketSMTPSocket, SSLSocket, SocketCore, TCPSocket classes.