Pop3 Class
Provides properties and methods for connecting to a POP3 server and downloading and deleting e-mail messages from a user account inbox.
Inheritance Hierarchy
SystemObject
  MailBee.Pop3MailPop3

Namespace: MailBee.Pop3Mail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax
public class Pop3 : IComponent, IDisposable

The Pop3 type exposes the following members.

Constructors
  NameDescription
Public methodPop3
Creates an instance of Pop3 class.
Public methodPop3(String)
Creates and unlocks an instance of Pop3 class.
Top
Methods
  NameDescription
Public methodAbort
Forces MailBee to cancel all pending operations and close all opened connections as soon as possible.
Public methodCode exampleBeginConnect Obsolete.
Begins an asynchronous request for a connecting to a POP3 server.
Public methodCode exampleBeginDeleteMessage Obsolete.
Begins an asynchronous request for flagging the specified message for deletion from the server.
Public methodCode exampleBeginDeleteMessages Obsolete.
Begins an asynchronous request for flagging the specified range of messages for deletion from the server.
Public methodBeginDisconnect Obsolete.
Begins an asynchronous request for a disconnection from the server.
Public methodCode exampleBeginDownloadMessage Obsolete.
Begins an asynchronous request for downloading the specified message header or entire message from the server.
Public methodCode exampleBeginDownloadMessages Obsolete.
Begins an asynchronous request for downloading the entire or partial messages in the specified range from the server.
Public methodCode exampleBeginExecuteCustomCommand Obsolete.
Begins an asynchronous request for sending the specified user-defined command to the server and getting the response.
Public methodCode exampleBeginLogin Obsolete.
Begins an asynchronous request for a logging in an account on a POP3 server.
Public methodCode exampleBeginStartTls Obsolete.
Begins an asynchronous request to start TLS/SSL negotiation with the server.
Public methodCode exampleConnect(String)
Connects to a POP3 server on the standard POP3 port (110).
Public methodCode exampleConnect(String, Int32)
Connects to a POP3 server.
Public methodCode exampleConnect(String, Int32, Boolean)
Connects to a POP3 server.
Public methodConnectAsync(String)
async/await version of Connect(String).
Public methodConnectAsync(String, Int32)
async/await version of Connect(String, Int32).
Public methodConnectAsync(String, Int32, Boolean)
async/await version of Connect(String, Int32, Boolean).
Public methodCode exampleDeleteMessage
Flags the specified message for deletion from the server.
Public methodDeleteMessageAsync
async/await version of DeleteMessage(Int32).
Public methodCode exampleDeleteMessages
Flags all the messages in the inbox for deletion from the server.
Public methodCode exampleDeleteMessages(Int32, Int32)
Flags the specified range of messages for deletion from the server.
Public methodDeleteMessagesAsync
Public methodDeleteMessagesAsync(Int32, Int32)
async/await version of DeleteMessages(Int32, Int32).
Public methodCode exampleDisconnect
Disconnects from the POP3 server and releases any used resources.
Public methodDisconnectAsync
Public methodDispose
Closes opened network connections (if any) and releases any used system resources.
Protected methodDispose(Boolean)
When overridden in a derived class, must release unmananged and optionally managed resources used by the component.
Public methodCode exampleDownloadEntireMessage
Completely downloads the specified message from the server.
Public methodDownloadEntireMessageAsync
async/await version of DownloadEntireMessage(Int32).
Public methodCode exampleDownloadEntireMessages
Completely downloads all the messages from the inbox on the server.
Public methodCode exampleDownloadEntireMessages(Int32, Int32)
Completely downloads the messages in the specified range from the server.
Public methodDownloadEntireMessagesAsync
Public methodDownloadEntireMessagesAsync(Int32, Int32)
async/await version of DownloadEntireMessages(Int32, Int32).
Public methodCode exampleDownloadMessageHeader(Int32)
Downloads the header of the specified message from the server.
Public methodCode exampleDownloadMessageHeader(Int32, Int32)
Downloads the header and the specified number of body lines of the message on the server.
Public methodDownloadMessageHeaderAsync(Int32)
async/await version of DownloadMessageHeader(Int32).
Public methodDownloadMessageHeaderAsync(Int32, Int32)
async/await version of DownloadMessageHeader(Int32, Int32).
Public methodCode exampleDownloadMessageHeaders
Downloads headers of all messages in the inbox on the server.
Public methodCode exampleDownloadMessageHeaders(Int32, Int32)
Downloads the header of each message in the specified range from the server.
Public methodCode exampleDownloadMessageHeaders(Int32, Int32, Int32)
Downloads the header and the specified number of body lines of each message in the specified range from the server.
Public methodDownloadMessageHeadersAsync
Public methodDownloadMessageHeadersAsync(Int32, Int32)
async/await version of DownloadMessageHeaders(Int32, Int32).
Public methodDownloadMessageHeadersAsync(Int32, Int32, Int32)
Public methodEndConnect
Ends the pending asynchronous connection request.
Public methodEndDeleteMessage
Ends the pending asynchronous request for flagging the message for deletion.
Public methodEndDeleteMessages
Ends the pending asynchronous request for flagging the range of messages for deletion.
Public methodEndDisconnect
Ends a pending asynchronous disconnection request.
Public methodEndDownloadMessage
Ends the pending asynchronous request for downloading the message and returns the downloaded message.
Public methodEndDownloadMessages
Ends the pending asynchronous request for downloading the messages and returns the downloaded messages.
Public methodEndExecuteCustomCommand
Ends the pending asynchronous request for sending user-defined command to the server.
Public methodEndLogin
Ends the pending asynchronous login request.
Public methodEndStartTls
Ends a pending asynchronous TLS/SSL negotiation request.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodCode exampleExecuteCustomCommand
Sends user-defined command to the server and receives the server response to this command.
Public methodExecuteCustomCommandAsync
async/await version of ExecuteCustomCommand(String, Boolean).
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetErrorDescription
Returns a textual description of the last error.
Public methodCode exampleGetExtension
Returns the name or parameters of the specified POP3 capability.
Public methodCode exampleGetExtensions
Returns a reference to the key-value list of the server capabilities.
Public methodGetExtensionsAsync
Public methodGetExtensionValue
Returns the parameters of the specified POP3 capability, or an empty string if the capability has no parameters.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetMessageIndexFromUid
Gets the message number of the message to which the specified Unique-ID is assigned.
Public methodGetMessageSize
Gets the length (in bytes) of the specified message in the inbox.
Public methodCode exampleGetMessageSizes
Gets the array of lengths (in bytes) of all messages in the inbox. The array is zero-based.
Public methodGetMessageSizesAsync
Public methodGetMessageUidFromIndex
Gets the Unique-ID string assigned to the specified message in the inbox on the server.
Public methodCode exampleGetMessageUids
Gets the array of Unique-ID's of all messages in the inbox. The array is zero-based.
Public methodGetMessageUidsAsync
Public methodGetServerResponse
Returns the last response from the server.
Public methodGetSocket
Returns the underlying Socket MailBee uses for the current network connection.
Public methodGetSocketError
Returns a Win32 error code of the last socket-related error.
Public methodGetStream
Returns the underlying Stream MailBee uses for the current network connection.
Public methodCode exampleGetSupportedAuthMethods
Returns a set of flags indicating which authentication methods are supported by the server.
Public methodGetSupportedAuthMethodsAsync
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodLast
Gets the message number of the last message ever accessed in this mailbox during actual or all prior POP3 sessions.
Public methodLastAsync
Public methodCode exampleLogin(String, String)
Logs in a mailbox on the POP3 server.
Public methodCode exampleLogin(String, String, AuthenticationMethods)
Logs in a mailbox on the POP3 server.
Public methodCode exampleLogin(String, String, AuthenticationMethods, AuthenticationOptions, SaslMethod)
Logs in a mailbox on the POP3 server.
Public methodCode exampleLogin(String, String, String, String, AuthenticationMethods, AuthenticationOptions, SaslMethod)
Logs in a mailbox on the POP3 server.
Public methodLoginAsync(String, String)
async/await version of Login(String, String).
Public methodLoginAsync(String, String, AuthenticationMethods)
Public methodLoginAsync(String, String, AuthenticationMethods, AuthenticationOptions, SaslMethod)
Public methodLoginAsync(String, String, String, String, AuthenticationMethods, AuthenticationOptions, SaslMethod)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodNoop
Sends a NOOP command to the server.
Public methodNoop2
Sends a command to the POP3 server to keep the connection alive.
Public methodNoop2Async
Public methodNoopAsync
Protected methodOnConnected
Used by MailBee to raise Connected event.
Protected methodOnDataReceived
Used by MailBee to raise DataReceived event.
Protected methodOnDataSent
Used by MailBee to raise DataSent event.
Protected methodOnDisconnected
Used by MailBee to raise Disconnected event.
Protected methodOnErrorOccurred
Used by MailBee to raise ErrorOccurred event.
Protected methodOnHostResolved
Used by MailBee to raise HostResolved event.
Protected methodOnLoggedIn
Used by MailBee to raise LoggedIn event.
Protected methodOnLogNewEntry
Used by MailBee to raise LogNewEntry event.
Protected methodOnLowLevelDataReceived
Used by MailBee to raise LowLevelDataReceived event.
Protected methodOnLowLevelDataSent
Used by MailBee to raise LowLevelDataSent event.
Protected methodOnMessageDataChunkReceived
Used by MailBee to raise MessageDataChunkReceived event.
Protected methodOnMessageDownloaded
Used by MailBee to raise MessageDownloaded event.
Protected methodOnSocketConnected
Used by MailBee to raise SocketConnected event.
Protected methodOnSocketCreating
Used by MailBee to raise SocketCreating event.
Protected methodOnTlsStarted
Used by MailBee to raise TlsStarted event.
Public methodStatic memberCode exampleQuickDownloadMessage(String, String, String, Int32)
Completely downloads the specified message from the server, in a single line of code.
Public methodStatic memberCode exampleQuickDownloadMessage(String, String, String, Int32, Int32)
Downloads the specified message (entire message or message header only) from the server, in a single line of code.
Public methodStatic memberCode exampleQuickDownloadMessages(String, String, String)
Completely downloads all the messages in the inbox on the server, in a single line of code.
Public methodStatic memberCode exampleQuickDownloadMessages(String, String, String, Int32)
Downloads all the messages (entire messages or message headers only) in the inbox on the server, in a single line of code.
Public methodResetDeletes
Resets the POP3 session, and cancels the deleted status for all messages flagged for deletion in the inbox.
Public methodResetDeletesAsync
Public methodResetState
Resets the internal state of the component.
Public methodCode exampleStartTls
Requests the mail server to start TLS/SSL negotiation and protect the existing connection with a security layer.
Public methodStartTlsAsync
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWait Obsolete.
Waits until the currently running (if any) asynchronous method is finished.
Public methodWait(Int32) Obsolete.
Waits the completion of the currently running (if any) asynchronous method for the specified amount of time.
Top
Properties
  NameDescription
Public propertyEnableLastDownloaded
Gets or sets whether MailBee should save currently downloaded messages in LastDownloadedMessages property.
Public propertyInboxMessageCount
Gets the number of messages in the inbox.
Public propertyInboxPreloadOptions
Gets or sets the status of whether MailBee will download the list of message sizes and/or the list of message lengths during logging in the inbox.
Public propertyInboxSize
Gets the total size (in bytes) occupied by all the messages in the inbox.
Public propertyIsAborted
Indicates whether Abort method has been called for the component.
Public propertyIsBusy
Indicates whether the component is performing a lengthy operation.
Public propertyIsConnected
Indicates whether the component is connected to the server.
Public propertyIsLoggedIn
Indicates whether the component has already successfully authenticated on the server and logged in the user account.
Public propertyIsSslConnection
Indicates whether the current connection (if any) iss secured with TLS/SSL layer.
Public propertyCode exampleLastDownloadedMessages
Gets the collection of the messages downloaded to the current moment.
Public propertyLastResult
Gets a numeric code of the last error.
Public propertyStatic memberLicenseKey Obsolete.
Assigns the license key.
Public propertyCode exampleLog
Gets the object used for logging MailBee activities into a file or memory buffer.
Public propertyCode exampleProxy
Provides access to the settings which allow MailBee to connect to a mail server via a proxy server.
Public propertyRaiseEvents
Gets or sets whether the component will raise any events.
Public propertyRaiseEventsViaMessageLoop
Gets or sets whether the events will be raised on the message loop of the application or not.
Public propertyRequestEncoding
Gets or sets the encoding used to convert a string into a bytes stream which is then sent to the server.
Public propertyResponseEncoding
Gets or sets the encoding used to convert a byte data received from the server into a string.
Public propertySite
Gets or sets the object to be used as a site for the component.
Public propertyCode exampleSslCertificates
Provides access to the client and server SSL certificate settings.
Public propertyCode exampleSslMode
Gets or sets how the component should establish TLS/SSL connection with the mail server.
Public propertySslProtocol
Gets or sets the security protocol to be used for performing TLS/SSL negotiation and data encryption.
Public propertySynchronizingObject
Gets or sets the object used to marshal the calls of the event handlers.
Public propertyThrowExceptions
Gets or sets whether the component will throw exceptions on errors.
Public propertyTimeout
Gets or sets the amount of time (in milliseconds) the component will wait for a response from the server.
Public propertyTrialDaysLeft
Gets the number of days left to the date of the trial license key expiration.
Public propertyVersion
Gets the version of the MailBee assembly.
Top
Events
  NameDescription
Public eventCode exampleConnected
Occurs when the connection with the server is successfully established.
Public eventCode exampleDataReceived
Occurs when data is received from the POP3 server.
Public eventCode exampleDataSent
Occurs when data is sent to the POP3 server.
Public eventCode exampleDisconnected
Occurs when the connection with the server gets closed.
Public eventDisposed
Occurs after the component was disposed.
Public eventCode exampleErrorOccurred
Occurs when the MailBeeException is thrown.
Public eventCode exampleHostResolved
Occurs when the POP3 server name is successully resolved into IP address(es).
Public eventCode exampleLoggedIn
Occurs when the component successfully authenticates the user on the server and logs in the user account.
Public eventCode exampleLogNewEntry
Occurs when an entry is written into the log file (or into the memory buffer if Pop3.Log.MemoryLog is true).
Public eventCode exampleLowLevelDataReceived
Occurs when data is received from the connected socket.
Public eventCode exampleLowLevelDataSent
Occurs when data is sent to the connected socket.
Public eventCode exampleMessageDataChunkReceived
Occurs on progress of downloading message source data from the server.
Public eventCode exampleMessageDownloaded
Occurs when a message was downloaded from the server.
Public eventCode exampleSocketConnected
Occurs when the POP3 server accepts the connection attempt and opens the transmission channel between the remote host (POP3 server) and the client (MailBee).
Public eventCode exampleSocketCreating
Occurs when MailBee needs a new socket object for establishing a connection with the POP3 server.
Public eventCode exampleTlsStarted
Occurs when the connection with the server becomes secure.
Top
Remarks
You can perform the following operations using this class:
  • Download entire messages with body and attachments
  • Download message headers (and optionally, the part of message bodies)
  • Delete messages from the POP3 server
  • Send user-defined commands to the POP3 server
  • Login to a user account using a number of authentication methods (including secure methods and OAuth2)
  • Take advantage of POP3 pipelining which dramatically speeds up batch retrieval or deleting messages
  • Collect inbox statistics like number of messages and total size of all messages
  • Download entire messages or message headers with a single line of code (using static methods)
  • Establish secure connection with TLS/SSL enabled POP3 server
  • Establish connection via a proxy server (SOCKS4, SOCKS5, and HTTP proxy are supported)
Examples
This sample connects to a POP3 server, logs in using the most secure method supported by this server, downloads headers for the first 10 messages in the inbox, and prints From:, To:, and Subject: field values for every message into Console.
// To use the code below, import MailBee namespaces at the top of your code
using MailBee;
using MailBee.Pop3Mail;
using MailBee.Mime;

// The actual code (put it into a method of your class).
Pop3 pop = new Pop3();
pop.Connect("mail.domain.com");
pop.Login("jdoe", "secret");
MailMessageCollection msgs = pop.DownloadMessageHeaders(1, 10);
foreach (MailMessage msg in msgs)
{
    Console.WriteLine("From: " + msg.From.Email + ", To: " + msg.To.AsString + ", Subject: " + msg.Subject);
}
pop.Disconnect();
See Also