TCPSocket → SocketCore → Object

POP3Socket Class

Used to retrieve and manage messages on a POP3 mail server.

Events
ConnectionEstablished | MessageReceived
Disconnected | RollbackSuccessful
ListReceived | ServerAvailable
LoginSuccessful | ServerCommandReply
MessageCount | ServerError
MessageDeleted | TopLinesReceived

Properties
EncryptPassword
Password
Username

Methods
CheckServerConnection | ListMessages
Connect | RetrieveLines
CountMessages | RetrieveMessage
DeleteMessage | RollbackServer
DisconnectFromServer | SendServerCommand

# Notes

If you use a constructor in a subclass of POP3Socket, 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 example in the Action event of a PushButton establishes a connection to a POP3 server. The POP3Socket control, POP3Socket1, has been added to the window. The method gets the name of the server, username, and password from the contents of the EditFields, ServerFld, UserNameFld, and PasswordFld.

If Me.caption = "Connect" then
//get POP3 sever address and port to use
POP3socket1.Address = ServerFld.text
POP3socket1.Port = 110
//get account info
POP3Socket1.Username = UsernameFld.text
POP3Socket1.Password = passwordFld.text
//establish connection
POP3Socket1.connect
Me.Caption = "Disconnect" //change button text while connected
else
POP3Socket1.DisconnectFromServer
Me.caption = "Connect"
End if

The following example in the MessageReceived event of the POP3Socket control, displays the message in the multiline EditField, BodyFld.

Sub MessageReceived (ID as Integer, Email as EmailMessage)
Dim s as String
// display the message
s = Email.bodyHTML
if s = "" then
s = Email.bodyPlainText
end if
BodyFld.text = ReplaceAll(s, Chr(13)+ Chr(10), Chr(13))

The following example in the TopLinesReceived event populates a ListBox with summary information on the email that was received. After populating the ListBox, it checks against the window property MessageTotal, which contains the result from a call to CountMessages, to see if there are any more message on the server. MessageTotal is assigned the value of the Count parameter in the MessageCount event

Sub TopLinesReceived (ID as Integer, Email as EmailMessage)
// headers received. populate the Listbox
ListBox1.AddRow Email.Subject()
ListBox1.Cell(ListBox1.lastIndex,1) = Email.FromAddress()
ListBox1.Cell(ListBox1.lastIndex,2) = Str(ID)
if ID < MessageTotal then // there are still messages left
Me.RetrieveLines id+1,0/ / get the next message headers
End if

.

# See Also

EmailMessage, HTTPSocket, SMTPSocket, SocketCore, TCPSocket classes.