Post Office Protocol Control
The SocketTools Post Office Protocol (POP3) ActiveX control enables your application to retrieve messages stored on a mail server, and manage those messages on behalf of the user. This is the most popular e-mail protocol used by Internet Service Providers (ISPs) and the SocketTools control provides a complete interface for accessing a user's mailbox. This control is typically used in conjunction with the Mail Message control, which is used to process the messages that are retrieved from the server. To download a free evaluation copy of SocketTools or for more information about this component, please select one of the following links:
ActiveX Control Overview
The Post Office Protocol (POP3) is used to manage the contents of a user's mailbox and download messages from the mail server to the local system. Methods are provided for listing available messages and then retrieving those messages, storing them either in files or in memory. Once a user's messages have been downloaded to the local system, they are typically removed from the server. Most Internet Service Providers support the POP3 standard protocol and the control has been designed to be compatible with a wide variety of servers, and includes support for a number of popular protocol extensions. This control is typically used in conjunction with the Mail Message control, which is used to process the messages that are retrieved from the server.
This control supports secure connections using the standard SSL and TLS protocols. Both implicit and explicit SSL connections can be established, enabling the library to work with a wide variety of servers. A SocketTools Secure Visual Edition license must be purchased to use the security features in this control.
Control Features
The following are just some of the features in the SocketTools Post Office Protocol control:
- Standard ATL based ActiveX control compatible with most languages
- Low resource utilization and no external dependencies on third-party libraries
- Fully compatible with Visual Studio .NET languages
- Includes both high level and lower level interfaces for maximum flexibility
- List all of the messages that are available in the user's mailbox
- Download messages from the mail server to the local system
- Retrieve only the message headers without downloading the entire message
- Support for both synchronous and asynchronous network connections
- Thread-safe implementation with full support for multithreaded applications
- An extensive Developer's Guide and online Technical Reference
- A professional technical support staff and extensive online support resources
- No runtime licensing fees or additional royalties
- A trusted company with over 10 years experience developing Internet components
Code Example
The following code example in Visual Basic demonstrates how the control can be used to retrieve all the messages from a user's Inbox and store them on the local system:
' Connect to the specified POP3 server, authenticating with a
' username and password provided by the user
nError = PopClient1.Connect(strHostName, , strUserName, strPassword)
If nError <> 0 Then
MsgBox PopClient1.LastErrorString, vbExclamation
Exit Sub
End If
' For each message that is available in the user's Inbox, retrieve
' it and store it on a local text file
For nMessage = 1 To PopClient1.MessageCount
strFileName = strMailDir & "\message" & nMessage & ".txt"
nError = PopClient1.StoreMessage(nMessage, strFileName)
If nError <> 0 Then
MsgBox PopClient1.LastErrorString, vbExclamation
Exit Sub
End If
Next
' Disconnect from the mail server
PopClient1.Disconnect
In this example, there are three methods that are called: Connect, which establishes the connection to the mail server; StoreMessage which retrieves the contents of the message and stores it in a file on the local system; and Disconnect, which closes the connection to the server.
As you can see, most of the code is actually related to error checking and comments, with only a few lines of code required to retrieve the messages from the server. If you wanted to store the contents of the message in a string or byte array, then you would use the GetMessage method instead but all of the other code would remain the same. You could also use this control in conjunction with the Mail Message control to parse the contents of the message and display specific portions of the message to the end user.