Click or drag to resize
MimeKit

Pop3Client Class

A POP3 client that can be used to retrieve messages from a server.
Inheritance Hierarchy
SystemObject
  MailKitMailService
    MailKitMailSpool
      MailKit.Net.Pop3Pop3Client

Namespace: MailKit.Net.Pop3
Assembly: MailKit (in MailKit.dll) Version: 4.3.0
Syntax
C#
public class Pop3Client : MailSpool, IPop3Client, 
	IMailSpool, IMailService, IDisposable, IEnumerable<MimeMessage>, 
	IEnumerable

The Pop3Client type exposes the following members.

Constructors
 NameDescription
Public methodPop3Client Initializes a new instance of the Pop3Client class.
Public methodCode examplePop3Client(IProtocolLogger) Initializes a new instance of the Pop3Client class.
Top
Properties
 NameDescription
Public propertyCode exampleAuthenticationMechanisms Gets the authentication mechanisms supported by the POP3 server.
(Overrides MailServiceAuthenticationMechanisms)
Public propertyCode exampleCapabilities Gets the capabilities supported by the POP3 server.
Public propertyCheckCertificateRevocation Get or set whether connecting via SSL/TLS should check certificate revocation.
(Inherited from MailService)
Public propertyClientCertificates Get or set the client SSL certificates.
(Inherited from MailService)
Public propertyCode exampleCount Get the number of messages available in the message spool.
(Overrides MailSpoolCount)
Public propertyCode exampleExpirePolicy Gets the expiration policy.
Public propertyImplementation Gets the implementation details of the server.
Public propertyIsAuthenticated Get whether or not the client is currently authenticated with the POP3 server.
(Overrides MailServiceIsAuthenticated)
Public propertyCode exampleIsConnected Gets whether or not the client is currently connected to an POP3 server.
(Overrides MailServiceIsConnected)
Public propertyIsEncrypted Get whether or not the connection is encrypted (typically via SSL or TLS).
(Overrides MailServiceIsEncrypted)
Public propertyIsSecure Get whether or not the connection is secure (typically via SSL or TLS).
(Overrides MailServiceIsSecure)
Public propertyIsSigned Get whether or not the connection is signed (typically via SSL or TLS).
(Overrides MailServiceIsSigned)
Public propertyLocalEndPoint Get or set the local IP end point to use when connecting to the remote host.
(Inherited from MailService)
Public propertyCode exampleLoginDelay Gets the minimum delay, in milliseconds, between logins.
Protected propertyProtocol Gets the protocol supported by the message service.
(Overrides MailServiceProtocol)
Public propertyProtocolLogger Get the protocol logger.
(Inherited from MailService)
Public propertyProxyClient Get or set the proxy client to use when connecting to a remote host.
(Inherited from MailService)
Public propertyCode exampleServerCertificateValidationCallback Get or set a callback function to validate the server certificate.
(Inherited from MailService)
Public propertySize Get the size of the POP3 mailbox, in bytes.
Public propertyCode exampleSslCipherAlgorithm Get the negotiated SSL or TLS cipher algorithm.
(Overrides MailServiceSslCipherAlgorithm)
Public propertyCode exampleSslCipherStrength Get the negotiated SSL or TLS cipher algorithm strength.
(Overrides MailServiceSslCipherStrength)
Public propertyCode exampleSslHashAlgorithm Get the negotiated SSL or TLS hash algorithm.
(Overrides MailServiceSslHashAlgorithm)
Public propertyCode exampleSslHashStrength Get the negotiated SSL or TLS hash algorithm strength.
(Overrides MailServiceSslHashStrength)
Public propertyCode exampleSslKeyExchangeAlgorithm Get the negotiated SSL or TLS key exchange algorithm.
(Overrides MailServiceSslKeyExchangeAlgorithm)
Public propertyCode exampleSslKeyExchangeStrength Get the negotiated SSL or TLS key exchange algorithm strength.
(Overrides MailServiceSslKeyExchangeStrength)
Public propertyCode exampleSslProtocol Get the negotiated SSL or TLS protocol version.
(Overrides MailServiceSslProtocol)
Public propertySslProtocols Get or set the set of enabled SSL and/or TLS protocol versions that the client is allowed to use.
(Inherited from MailService)
Public propertySupportsUids Gets whether or not the Pop3Client supports referencing messages by UIDs.
(Overrides MailSpoolSupportsUids)
Public propertySyncRoot Gets an object that can be used to synchronize access to the POP3 server.
(Overrides MailServiceSyncRoot)
Public propertyTimeout Gets or sets the timeout for network streaming operations, in milliseconds.
(Overrides MailServiceTimeout)
Top
Methods
 NameDescription
Public methodAuthenticate(ICredentials, CancellationToken) Authenticate using the supplied credentials.
(Inherited from MailService)
Public methodAuthenticate(SaslMechanism, CancellationToken) Authenticate using the specified SASL mechanism.
(Overrides MailServiceAuthenticate(SaslMechanism, CancellationToken))
Public methodAuthenticate(Encoding, ICredentials, CancellationToken) Authenticate using the supplied credentials.
(Overrides MailServiceAuthenticate(Encoding, ICredentials, CancellationToken))
Public methodCode exampleAuthenticate(String, String, CancellationToken) Authenticate using the specified user name and password.
(Inherited from MailService)
Public methodAuthenticate(Encoding, String, String, CancellationToken) Authenticate using the specified user name and password.
(Inherited from MailService)
Public methodAuthenticateAsync(ICredentials, CancellationToken) Asynchronously authenticate using the supplied credentials.
(Inherited from MailService)
Public methodAuthenticateAsync(SaslMechanism, CancellationToken) Asynchronously authenticate using the specified SASL mechanism.
(Overrides MailServiceAuthenticateAsync(SaslMechanism, CancellationToken))
Public methodAuthenticateAsync(Encoding, ICredentials, CancellationToken) Asynchronously authenticates using the supplied credentials.
(Overrides MailServiceAuthenticateAsync(Encoding, ICredentials, CancellationToken))
Public methodAuthenticateAsync(String, String, CancellationToken) Asynchronously authenticate using the specified user name and password.
(Inherited from MailService)
Public methodAuthenticateAsync(Encoding, String, String, CancellationToken) Asynchronously authenticate using the specified user name and password.
(Inherited from MailService)
Public methodCode exampleConnect(Uri, CancellationToken) Establish a connection to the specified mail server.
(Inherited from MailService)
Public methodConnect(String, Int32, Boolean, CancellationToken) Establish a connection to the specified mail server.
(Inherited from MailService)
Public methodCode exampleConnect(String, Int32, SecureSocketOptions, CancellationToken) Establish a connection to the specified POP3 or POP3/S server.
(Overrides MailServiceConnect(String, Int32, SecureSocketOptions, CancellationToken))
Public methodConnect(Socket, String, Int32, SecureSocketOptions, CancellationToken) Establish a connection to the specified POP3 or POP3/S server using the provided socket.
(Overrides MailServiceConnect(Socket, String, Int32, SecureSocketOptions, CancellationToken))
Public methodConnect(Stream, String, Int32, SecureSocketOptions, CancellationToken) Establish a connection to the specified POP3 or POP3/S server using the provided stream.
(Overrides MailServiceConnect(Stream, String, Int32, SecureSocketOptions, CancellationToken))
Public methodConnectAsync(Uri, CancellationToken) Asynchronously establish a connection to the specified mail server.
(Inherited from MailService)
Public methodConnectAsync(String, Int32, Boolean, CancellationToken) Asynchronously establish a connection to the specified mail server.
(Inherited from MailService)
Public methodCode exampleConnectAsync(String, Int32, SecureSocketOptions, CancellationToken) Asynchronously establish a connection to the specified POP3 or POP3/S server.
(Overrides MailServiceConnectAsync(String, Int32, SecureSocketOptions, CancellationToken))
Public methodConnectAsync(Socket, String, Int32, SecureSocketOptions, CancellationToken) Asynchronously establish a connection to the specified POP3 or POP3/S server using the provided socket.
(Overrides MailServiceConnectAsync(Socket, String, Int32, SecureSocketOptions, CancellationToken))
Public methodConnectAsync(Stream, String, Int32, SecureSocketOptions, CancellationToken) Asynchronously establish a connection to the specified POP3 or POP3/S server using the provided stream.
(Overrides MailServiceConnectAsync(Stream, String, Int32, SecureSocketOptions, CancellationToken))
Public methodDeleteAllMessages Mark all messages for deletion.
(Overrides MailSpoolDeleteAllMessages(CancellationToken))
Public methodDeleteAllMessagesAsync Asynchronously mark all messages for deletion.
(Overrides MailSpoolDeleteAllMessagesAsync(CancellationToken))
Public methodCode exampleDeleteMessage Mark the specified message for deletion.
(Overrides MailSpoolDeleteMessage(Int32, CancellationToken))
Public methodCode exampleDeleteMessageAsync Asynchronously mark the specified message for deletion.
(Overrides MailSpoolDeleteMessageAsync(Int32, CancellationToken))
Public methodDeleteMessages(IListInt32, CancellationToken) Mark the specified messages for deletion.
(Overrides MailSpoolDeleteMessages(IListInt32, CancellationToken))
Public methodCode exampleDeleteMessages(Int32, Int32, CancellationToken) Mark the specified range of messages for deletion.
(Overrides MailSpoolDeleteMessages(Int32, Int32, CancellationToken))
Public methodDeleteMessagesAsync(IListInt32, CancellationToken) Asynchronously mark the specified messages for deletion.
(Overrides MailSpoolDeleteMessagesAsync(IListInt32, CancellationToken))
Public methodCode exampleDeleteMessagesAsync(Int32, Int32, CancellationToken) Asynchronously mark the specified range of messages for deletion.
(Overrides MailSpoolDeleteMessagesAsync(Int32, Int32, CancellationToken))
Public methodCode exampleDisconnect Disconnect the service.
(Overrides MailServiceDisconnect(Boolean, CancellationToken))
Public methodCode exampleDisconnectAsync Asynchronously disconnect the service.
(Overrides MailServiceDisconnectAsync(Boolean, CancellationToken))
Public methodDispose Releases all resource used by the MailService object.
(Inherited from MailService)
Protected methodDispose(Boolean) Releases the unmanaged resources used by the Pop3Client and optionally releases the managed resources.
(Overrides MailServiceDispose(Boolean))
Public methodEnableUTF8 Enable UTF8 mode.
Public methodEnableUTF8Async Asynchronously enable UTF8 mode.
Public methodEquals
(Inherited from Object)
Protected methodFinalize Releases unmanaged resources and performs other cleanup operations before the MailService is reclaimed by garbage collection.
(Inherited from MailService)
Public methodGetEnumerator Get an enumerator for the messages in the folder.
(Overrides MailSpoolGetEnumerator)
Public methodGetHashCode
(Inherited from Object)
Public methodGetLanguages Get the list of languages supported by the POP3 server.
Public methodGetLanguagesAsync Asynchronously get the list of languages supported by the POP3 server.
Public methodCode exampleGetMessage Get the message at the specified index.
(Overrides MailSpoolGetMessage(Int32, CancellationToken, ITransferProgress))
Public methodCode exampleGetMessageAsync Asynchronously get the message at the specified index.
(Overrides MailSpoolGetMessageAsync(Int32, CancellationToken, ITransferProgress))
Public methodGetMessageCount Get the message count.
(Overrides MailSpoolGetMessageCount(CancellationToken))
Public methodGetMessageCountAsync Asynchronously get the message count.
(Overrides MailSpoolGetMessageCountAsync(CancellationToken))
Public methodGetMessageHeaders(IListInt32, CancellationToken) Get the headers for the messages at the specified indexes.
(Overrides MailSpoolGetMessageHeaders(IListInt32, CancellationToken))
Public methodGetMessageHeaders(Int32, CancellationToken) Get the headers for the message at the specified index.
(Overrides MailSpoolGetMessageHeaders(Int32, CancellationToken))
Public methodGetMessageHeaders(Int32, Int32, CancellationToken) Get the headers of the messages within the specified range.
(Overrides MailSpoolGetMessageHeaders(Int32, Int32, CancellationToken))
Public methodGetMessageHeadersAsync(IListInt32, CancellationToken) Asynchronously get the headers for the messages at the specified indexes.
(Overrides MailSpoolGetMessageHeadersAsync(IListInt32, CancellationToken))
Public methodGetMessageHeadersAsync(Int32, CancellationToken) Asynchronously get the headers for the message at the specified index.
(Overrides MailSpoolGetMessageHeadersAsync(Int32, CancellationToken))
Public methodGetMessageHeadersAsync(Int32, Int32, CancellationToken) Asynchronously get the headers of the messages within the specified range.
(Overrides MailSpoolGetMessageHeadersAsync(Int32, Int32, CancellationToken))
Public methodGetMessages(IListInt32, CancellationToken, ITransferProgress) Get the messages at the specified indexes.
(Overrides MailSpoolGetMessages(IListInt32, CancellationToken, ITransferProgress))
Public methodCode exampleGetMessages(Int32, Int32, CancellationToken, ITransferProgress) Get the messages within the specified range.
(Overrides MailSpoolGetMessages(Int32, Int32, CancellationToken, ITransferProgress))
Public methodGetMessagesAsync(IListInt32, CancellationToken, ITransferProgress) Asynchronously get the messages at the specified indexes.
(Overrides MailSpoolGetMessagesAsync(IListInt32, CancellationToken, ITransferProgress))
Public methodCode exampleGetMessagesAsync(Int32, Int32, CancellationToken, ITransferProgress) Asynchronously get the messages within the specified range.
(Overrides MailSpoolGetMessagesAsync(Int32, Int32, CancellationToken, ITransferProgress))
Public methodGetMessageSize Get the size of the specified message, in bytes.
(Overrides MailSpoolGetMessageSize(Int32, CancellationToken))
Public methodGetMessageSizeAsync Asynchronously get the size of the specified message, in bytes.
(Overrides MailSpoolGetMessageSizeAsync(Int32, CancellationToken))
Public methodGetMessageSizes Get the sizes for all available messages, in bytes.
(Overrides MailSpoolGetMessageSizes(CancellationToken))
Public methodGetMessageSizesAsync Asynchronously get the sizes for all available messages, in bytes.
(Overrides MailSpoolGetMessageSizesAsync(CancellationToken))
Public methodGetMessageUid Get the UID of the message at the specified index.
(Overrides MailSpoolGetMessageUid(Int32, CancellationToken))
Public methodGetMessageUidAsync Asynchronously get the UID of the message at the specified index.
(Overrides MailSpoolGetMessageUidAsync(Int32, CancellationToken))
Public methodCode exampleGetMessageUids Get the full list of available message UIDs.
(Overrides MailSpoolGetMessageUids(CancellationToken))
Public methodCode exampleGetMessageUidsAsync Asynchronously get the full list of available message UIDs.
(Overrides MailSpoolGetMessageUidsAsync(CancellationToken))
Public methodGetStream Get the message or header stream at the specified index.
(Overrides MailSpoolGetStream(Int32, Boolean, CancellationToken, ITransferProgress))
Public methodGetStreamAsync Asynchronously get the message or header stream at the specified index.
(Overrides MailSpoolGetStreamAsync(Int32, Boolean, CancellationToken, ITransferProgress))
Public methodGetStreams(IListInt32, Boolean, CancellationToken, ITransferProgress) Get the message or header streams at the specified indexes.
(Overrides MailSpoolGetStreams(IListInt32, Boolean, CancellationToken, ITransferProgress))
Public methodGetStreams(Int32, Int32, Boolean, CancellationToken, ITransferProgress) Get the message or header streams within the specified range.
(Overrides MailSpoolGetStreams(Int32, Int32, Boolean, CancellationToken, ITransferProgress))
Public methodGetStreamsAsync(IListInt32, Boolean, CancellationToken, ITransferProgress) Asynchronously get the message or header streams at the specified indexes.
(Overrides MailSpoolGetStreamsAsync(IListInt32, Boolean, CancellationToken, ITransferProgress))
Public methodGetStreamsAsync(Int32, Int32, Boolean, CancellationToken, ITransferProgress) Asynchronously get the message or header streams within the specified range.
(Overrides MailSpoolGetStreamsAsync(Int32, Int32, Boolean, CancellationToken, ITransferProgress))
Public methodGetType
(Inherited from Object)
Protected methodMemberwiseClone
(Inherited from Object)
Public methodNoOp Ping the POP3 server to keep the connection alive.
(Overrides MailServiceNoOp(CancellationToken))
Public methodNoOpAsync Ping the POP3 server to keep the connection alive.
(Overrides MailServiceNoOpAsync(CancellationToken))
Protected methodOnAuthenticated Raise the authenticated event.
(Inherited from MailService)
Protected methodOnConnected Raise the connected event.
(Inherited from MailService)
Protected methodOnDisconnected Raise the disconnected event.
(Inherited from MailService)
Public methodReset Reset the state of all messages marked for deletion.
(Overrides MailSpoolReset(CancellationToken))
Public methodResetAsync Asynchronously reset the state of all messages marked for deletion.
(Overrides MailSpoolResetAsync(CancellationToken))
Public methodSetLanguage Set the language used by the POP3 server for error messages.
Public methodSetLanguageAsync Asynchronously set the language used by the POP3 server for error messages.
Public methodToString
(Inherited from Object)
Top
Events
 NameDescription
Public eventAuthenticated Occurs when the client has been successfully authenticated.
(Inherited from MailService)
Public eventConnected Occurs when the client has been successfully connected.
(Inherited from MailService)
Public eventDisconnected Occurs when the client gets disconnected.
(Inherited from MailService)
Top
Remarks
The Pop3Client class supports both the "pop" and "pops" protocols. The "pop" protocol makes a clear-text connection to the POP3 server and does not use SSL or TLS unless the POP3 server supports the STLS extension. The "pops" protocol, however, connects to the POP3 server using an SSL-wrapped connection.
Example
C#
public static void DownloadMessages ()
{
    using (var client = new Pop3Client ()) {
        client.Connect ("pop.gmail.com", 995, SecureSocketOptions.SslOnConnect);

        client.Authenticate ("username", "password");

        for (int i = 0; i < client.Count; i++) {
            var message = client.GetMessage (i);

            // write the message to a file
            message.WriteTo (string.Format ("{0}.msg", i));

            // mark the message for deletion
            client.DeleteMessage (i);
        }

        client.Disconnect (true);
    }
}
See Also