View on GitHub

MailKit

MailKit: A cross-platform .NET mail-client library optimized for mobile.

Download this project as a .zip file Download this project as a tar.gz file

ImapClient Class

An IMAP client that can be used to retrieve messages from a server.

Syntax

public class ImapClient : MailKit.MailStore

Remarks

The MailKit.Net.Imap.ImapClient class supports both the "imap" and "imaps" protocols. The "imap" protocol makes a clear-text connection to the IMAP server and does not use SSL or TLS unless the IMAP server supports the STARTTLS extension (as defined by rfc3501). The "imaps" protocol, however, connects to the IMAP server using an SSL-wrapped connection.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

Members

See Also: Inherited members from MailKit.MailStore.

Public Constructors

Initializes a new instance of the MailKit.Net.Imap.ImapClient class.
Initializes a new instance of the MailKit.Net.Imap.ImapClient class.

Public Properties

[read-only]
override
AuthenticationMechanisms HashSet<string> . Get the authentication mechanisms supported by the IMAP server.
[read-only]
abstract
AuthenticationMechanisms HashSet<string> . Gets the authentication mechanisms supported by the mail server. (Inherited from MailKit.MailService.)
Capabilities ImapCapabilities . Get the capabilities supported by the IMAP server.
ClientCertificates System.Security.Cryptography.X509Certificates.X509CertificateCollection . Gets or sets the client SSL certificates. (Inherited from MailKit.MailService.)
[read-only]
override
Inbox MailKit.IMailFolder . Get the Inbox folder.
[read-only]
abstract
Inbox MailKit.IMailFolder . Gets the Inbox folder. (Inherited from MailKit.MailStore.)
[read-only]
override
IsConnected bool . Get whether or not the client is currently connected to an IMAP server.
[read-only]
abstract
IsConnected bool . Gets whether or not the client is currently connected to an mail server. (Inherited from MailKit.MailService.)
[read-only]
override
OtherNamespaces MailKit.FolderNamespaceCollection . Get the other namespaces.
[read-only]
abstract
OtherNamespaces MailKit.FolderNamespaceCollection . Gets the other namespaces. (Inherited from MailKit.MailStore.)
[read-only]
override
PersonalNamespaces MailKit.FolderNamespaceCollection . Get the personal namespaces.
[read-only]
abstract
PersonalNamespaces MailKit.FolderNamespaceCollection . Gets the personal namespaces. (Inherited from MailKit.MailStore.)
[read-only]
override
SharedNamespaces MailKit.FolderNamespaceCollection . Get the shared namespaces.
[read-only]
abstract
SharedNamespaces MailKit.FolderNamespaceCollection . Gets the shared namespaces. (Inherited from MailKit.MailStore.)
[read-only]
override
SupportsQuotas bool . Get whether or not the mail store supports quotas.
[read-only]
abstract
SupportsQuotas bool . Get whether or not the mail store supports quotas. (Inherited from MailKit.MailStore.)
[read-only]
override
SyncRoot object . Gets the lock object used by the default Async methods.
[read-only]
abstract
SyncRoot object . Gets an object that can be used to synchronize access to the folder. (Inherited from MailKit.MailService.)
[read-only]
ThreadingAlgorithms HashSet<MailKit.ThreadingAlgorithm> . Get the threading algorithms supported by the IMAP server.
override
Timeout int . Get or set the timeout for network streaming operations, in milliseconds.
abstract
Timeout int . Gets or sets the timeout for network streaming operations, in milliseconds. (Inherited from MailKit.MailService.)

Protected Properties

[read-only]
override
Protocol string . Get the protocol supported by the message service.
[read-only]
abstract
Protocol string . Gets the protocol supported by the message service. (Inherited from MailKit.MailService.)

Public Methods

override
Authenticate (System.Net.ICredentials, System.Threading.CancellationToken)
Authenticate using the supplied credentials.
abstract
Authenticate (System.Net.ICredentials, System.Threading.CancellationToken)
Authenticates using the supplied credentials. (Inherited from MailKit.MailService.)
Authenticate (string, string, System.Threading.CancellationToken)
Authenticates using the specified user name and password. (Inherited from MailKit.MailService.)
AuthenticateAsync (System.Net.ICredentials, System.Threading.CancellationToken) : System.Threading.Tasks.Task
Asynchronously authenticates using the supplied credentials. (Inherited from MailKit.MailService.)
AuthenticateAsync (string, string, System.Threading.CancellationToken) : System.Threading.Tasks.Task
Asynchronously authenticates using the specified user name and password. (Inherited from MailKit.MailService.)
override
Connect (Uri, System.Threading.CancellationToken)
Connect to the specified server.
abstract
Connect (Uri, System.Threading.CancellationToken)
Establishes a connection to the specified mail server. (Inherited from MailKit.MailService.)
Connect (string, int, bool, System.Threading.CancellationToken)
Establishes a connection to the specified mail server. (Inherited from MailKit.MailService.)
ConnectAsync (Uri, System.Threading.CancellationToken) : System.Threading.Tasks.Task
Asynchronously establishes a connection to the specified mail server. (Inherited from MailKit.MailService.)
ConnectAsync (string, int, bool, System.Threading.CancellationToken) : System.Threading.Tasks.Task
Asynchronously establishes a connection to the specified mail server. (Inherited from MailKit.MailService.)
override
Disconnect (bool, System.Threading.CancellationToken)
Disconnect the service.
abstract
Disconnect (bool, System.Threading.CancellationToken)
Disconnects the service. (Inherited from MailKit.MailService.)
DisconnectAsync (bool, System.Threading.CancellationToken) : System.Threading.Tasks.Task
Asynchronously disconnects the service. (Inherited from MailKit.MailService.)
Dispose ()
Releases all resource used by the MailKit.MailService object. (Inherited from MailKit.MailService.)
override
EnableQuickResync (System.Threading.CancellationToken)
Enable the QRESYNC feature.
abstract
EnableQuickResync (System.Threading.CancellationToken)
Enable the quick resynchronization feature. (Inherited from MailKit.MailStore.)
EnableQuickResyncAsync (System.Threading.CancellationToken) : System.Threading.Tasks.Task
Asynchronously enable the quick resynchronization feature. (Inherited from MailKit.MailStore.)
EnableUTF8 (System.Threading.CancellationToken)
Enable the UTF8=ACCEPT extension.
EnableUTF8Async (System.Threading.CancellationToken) : System.Threading.Tasks.Task
Enable the UTF8=ACCEPT extension.
Finalize ()
Releases unmanaged resources and performs other cleanup operations before the MailKit.MailService is reclaimed by garbage collection. (Inherited from MailKit.MailService.)
override
GetFolder (MailKit.FolderNamespace) : MailKit.IMailFolder
Get the folder for the specified namespace.
abstract
GetFolder (MailKit.FolderNamespace) : MailKit.IMailFolder
Get the folder for the specified namespace. (Inherited from MailKit.MailStore.)
override
GetFolder (MailKit.SpecialFolder) : MailKit.IMailFolder
Get the specified special folder.
abstract
GetFolder (MailKit.SpecialFolder) : MailKit.IMailFolder
Get the specified special folder. (Inherited from MailKit.MailStore.)
override
GetFolder (string, System.Threading.CancellationToken) : MailKit.IMailFolder
Get the folder for the specified path.
abstract
GetFolder (string, System.Threading.CancellationToken) : MailKit.IMailFolder
Get the folder for the specified path. (Inherited from MailKit.MailStore.)
GetFolderAsync (string, System.Threading.CancellationToken) : System.Threading.Tasks.Task<MailKit.IMailFolder>
Asynchronously get the folder for the specified path. (Inherited from MailKit.MailStore.)
Idle (System.Threading.CancellationToken, System.Threading.CancellationToken)
Toggle the MailKit.Net.Imap.ImapClient into the IDLE state.
IdleAsync (System.Threading.CancellationToken, System.Threading.CancellationToken) : System.Threading.Tasks.Task
Asynchronously toggle the MailKit.Net.Imap.ImapClient into the IDLE state.
override
NoOp (System.Threading.CancellationToken)
Ping the IMAP server to keep the connection alive.
abstract
NoOp (System.Threading.CancellationToken)
Pings the mail server to keep the connection alive. (Inherited from MailKit.MailService.)
NoOpAsync (System.Threading.CancellationToken) : System.Threading.Tasks.Task
Asynchronously pings the mail server to keep the connection alive. (Inherited from MailKit.MailService.)

Protected Methods

override
Dispose (bool)
Releases the unmanaged resources used by the MailKit.Net.Imap.ImapClient and optionally releases the managed resources.
Dispose (bool)
Releases the unmanaged resources used by the MailKit.MailService and optionally releases the managed resources. (Inherited from MailKit.MailService.)
OnAlert (MailKit.AlertEventArgs)
Raise the alert event. (Inherited from MailKit.MailStore.)
OnAuthenticated (string)
Raise the authenticated event. (Inherited from MailKit.MailService.)
OnConnected ()
Raise the connected event. (Inherited from MailKit.MailService.)
OnDisconnected ()
Raise the disconnected event. (Inherited from MailKit.MailService.)

Public Events

Alert Occurs when a remote message store receives an alert message from the server. (Inherited from MailKit.MailStore.)
Authenticated Occurs when the client has been successfully authenticated. (Inherited from MailKit.MailService.)
Connected Occurs when the client has been successfully connected. (Inherited from MailKit.MailService.)
Disconnected Occurs when the client gets disconnected. (Inherited from MailKit.MailService.)

Member Details

ImapClient Constructor

Initializes a new instance of the MailKit.Net.Imap.ImapClient class.

Syntax

public ImapClient ()

Remarks

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

ImapClient Constructor

Initializes a new instance of the MailKit.Net.Imap.ImapClient class.

Syntax

public ImapClient (MailKit.IProtocolLogger protocolLogger)

Parameters

protocolLogger
The protocol logger.

Exceptions

Type Reason
ArgumentNullException protocolLogger is null.

Remarks

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

Authenticate Method

Authenticate using the supplied credentials.

Syntax

public override void Authenticate (System.Net.ICredentials credentials, System.Threading.CancellationToken cancellationToken)

Parameters

credentials
The user's credentials.
cancellationToken
The cancellation token.

Exceptions

Type Reason
ArgumentNullException credentials is null.
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.
InvalidOperationException The MailKit.Net.Imap.ImapClient is not connected or is already authenticated.
OperationCanceledException The operation was canceled via the cancellation token.
System.Security.Authentication.AuthenticationException Authentication using the supplied credentials has failed.
MailKit.Security.SaslException A SASL authentication error occurred.
System.IO.IOException An I/O error occurred.
MailKit.Net.Imap.ImapProtocolException An IMAP protocol error occurred.
MailKit.Security.AuthenticationException Authentication using the supplied credentials has failed.

Remarks

If the server supports one or more SASL authentication mechanisms, then the SASL mechanisms that both the client and server support are tried in order of greatest security to weakest security. Once a SASL authentication mechanism is found that both client and server support, the credentials are used to authenticate.

If the server does not support SASL or if no common SASL mechanisms can be found, then LOGIN command is used as a fallback.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

AuthenticationMechanisms Property

Get the authentication mechanisms supported by the IMAP server.

Syntax

public override HashSet<string> AuthenticationMechanisms { get; }

Value

The authentication mechanisms.

Remarks

The authentication mechanisms are queried as part of the ImapClient.Connect(Uri, System.Threading.CancellationToken) method.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

Capabilities Property

Get the capabilities supported by the IMAP server.

Syntax

public ImapCapabilities Capabilities { get; set; }

Value

The capabilities.

Exceptions

Type Reason
ArgumentException Capabilities cannot be enabled, they may only be disabled.

Remarks

The capabilities will not be known until a successful connection has been made via the ImapClient.Connect(Uri, System.Threading.CancellationToken) method and may change as a side-effect of the ImapClient.Authenticate(System.Net.ICredentials, System.Threading.CancellationToken) method.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

Connect Method

Connect to the specified server.

Syntax

public override void Connect (Uri uri, System.Threading.CancellationToken cancellationToken)

Parameters

uri
The server URI. The Uri.Scheme should either be "imap" to make a clear-text connection or "imaps" to make an SSL connection.
cancellationToken
The cancellation token.

Exceptions

Type Reason
ArgumentNullException The uri is null.
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.
InvalidOperationException The MailKit.Net.Imap.ImapClient is already connected.
OperationCanceledException The operation was canceled via the cancellation token.
System.IO.IOException An I/O error occurred.
MailKit.Net.Imap.ImapProtocolException An IMAP protocol error occurred.
ArgumentException The uri is not an absolute URI.

Remarks

Establishes a connection to an IMAP or IMAP/S server. If the schema in the uri is "imap", a clear-text connection is made and defaults to using port 143 if no port is specified in the URI. However, if the schema in the uri is "imaps", an SSL connection is made using the MailKit.MailService.ClientCertificates and defaults to port 993 unless a port is specified in the URI.

It should be noted that when using a clear-text IMAP connection, if the server advertizes support for the STARTTLS extension, the client will automatically switch into TLS mode before authenticating unless the uri contains a query string to disable it.

If the IMAP server advertizes the COMPRESS extension and either does not support the STARTTLS extension or the uri explicitly disabled the use of the STARTTLS extension, then the client will automatically opt into using a compressed data connection to optimize bandwidth usage unless the uri contains a query string to explicitly disable it.

If a successful connection is made, the ImapClient.AuthenticationMechanisms and ImapClient.Capabilities properties will be populated.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

Disconnect Method

Disconnect the service.

Syntax

public override void Disconnect (bool quit, System.Threading.CancellationToken cancellationToken)

Parameters

quit
If set to true, a "LOGOUT" command will be issued in order to disconnect cleanly.
cancellationToken
The cancellation token.

Exceptions

Type Reason
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.

Remarks

If quit is true, a "LOGOUT" command will be issued in order to disconnect cleanly.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

Dispose Method

Releases the unmanaged resources used by the MailKit.Net.Imap.ImapClient and optionally releases the managed resources.

Syntax

protected override void Dispose (bool disposing)

Parameters

disposing
true to release both managed and unmanaged resources; false to release only the unmanaged resources.

Remarks

Releases the unmanaged resources used by the MailKit.Net.Imap.ImapClient and optionally releases the managed resources.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

EnableQuickResync Method

Enable the QRESYNC feature.

Syntax

public override void EnableQuickResync (System.Threading.CancellationToken cancellationToken)

Parameters

cancellationToken
The cancellation token.

Exceptions

Type Reason
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.
InvalidOperationException The MailKit.Net.Imap.ImapClient is not connected, not authenticated, or a folder has been selected.
NotSupportedException The IMAP server does not support the QRESYNC extension.
OperationCanceledException The operation was canceled via the cancellation token.
System.IO.IOException An I/O error occurred.
MailKit.Net.Imap.ImapProtocolException An IMAP protocol error occurred.

Remarks

The QRESYNC extension improves resynchronization performance of folders by querying the IMAP server for a list of changes when the folder is opened using the ImapFolder.Open(MailKit.FolderAccess, MailKit.UniqueId, ulong, IList<MailKit.UniqueId>,System.Threading.CancellationToken) method.

If this feature is enabled, the MailKit.MailFolder.MessageExpunged event is replaced with the MailKit.MailFolder.MessagesVanished event.

This method needs to be called immediately after ImapClient.Authenticate(System.Net.ICredentials, System.Threading.CancellationToken), before the opening of any folders.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

EnableUTF8 Method

Enable the UTF8=ACCEPT extension.

Syntax

public void EnableUTF8 (System.Threading.CancellationToken cancellationToken)

Parameters

cancellationToken
The cancellation token.

Exceptions

Type Reason
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.
InvalidOperationException The MailKit.Net.Imap.ImapClient is not connected, not authenticated, or a folder has been selected.
NotSupportedException The IMAP server does not support the UTF8=ACCEPT extension.
OperationCanceledException The operation was canceled via the cancellation token.
System.IO.IOException An I/O error occurred.
MailKit.Net.Imap.ImapProtocolException An IMAP protocol error occurred.

Remarks

Enables the UTF8=ACCEPT extension.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

EnableUTF8Async Method

Enable the UTF8=ACCEPT extension.

Syntax

public System.Threading.Tasks.Task EnableUTF8Async (System.Threading.CancellationToken cancellationToken)

Parameters

cancellationToken
The cancellation token.

Returns

An asynchronous task context.

Exceptions

Type Reason
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.
InvalidOperationException The MailKit.Net.Imap.ImapClient is not connected, not authenticated, or a folder has been selected.
NotSupportedException The IMAP server does not support the UTF8=ACCEPT extension.
OperationCanceledException The operation was canceled via the cancellation token.
System.IO.IOException An I/O error occurred.
MailKit.Net.Imap.ImapProtocolException An IMAP protocol error occurred.

Remarks

Enables the UTF8=ACCEPT extension.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

GetFolder Method

Get the folder for the specified namespace.

Syntax

public override MailKit.IMailFolder GetFolder (MailKit.FolderNamespace namespace)

Parameters

namespace
The namespace.

Returns

The folder.

Exceptions

Type Reason
ArgumentNullException namespace is null.
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.
InvalidOperationException

The MailKit.Net.Imap.ImapClient is not connected.

-or-

The MailKit.Net.Imap.ImapClient is not authenticated.

MailKit.FolderNotFoundException The folder could not be found.

Remarks

Gets the folder for the specified namespace.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

GetFolder Method

Get the specified special folder.

Syntax

public override MailKit.IMailFolder GetFolder (MailKit.SpecialFolder folder)

Parameters

folder
The type of special folder.

Returns

The folder if available; otherwise null.

Exceptions

Type Reason
ArgumentOutOfRangeException folder is out of range.
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.
InvalidOperationException

The MailKit.Net.Imap.ImapClient is not connected.

-or-

The MailKit.Net.Imap.ImapClient is not authenticated.

Remarks

Not all IMAP servers support special folders. Only IMAP servers supporting the ImapCapabilities.SpecialUse or ImapCapabilities.XList extensions may have special folders.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

GetFolder Method

Get the folder for the specified path.

Syntax

public override MailKit.IMailFolder GetFolder (string path, System.Threading.CancellationToken cancellationToken)

Parameters

path
The folder path.
cancellationToken
The cancellation token.

Returns

The folder.

Exceptions

Type Reason
ArgumentNullException path is null.
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.
InvalidOperationException

The MailKit.Net.Imap.ImapClient is not connected.

-or-

The MailKit.Net.Imap.ImapClient is not authenticated.

OperationCanceledException The operation was canceled via the cancellation token.
MailKit.FolderNotFoundException The folder could not be found.

Remarks

Gets the folder for the specified path.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

Idle Method

Toggle the MailKit.Net.Imap.ImapClient into the IDLE state.

Syntax

Parameters

doneToken
The cancellation token used to return to the non-idle state.
cancellationToken
The cancellation token.

Exceptions

Type Reason
ArgumentException doneToken must be cancellable (i.e. System.Threading.CancellationToken.None cannot be used).
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.
InvalidOperationException

The MailKit.Net.Imap.ImapClient is not connected.

-or-

The MailKit.Net.Imap.ImapClient is not authenticated.

-or-

A MailKit.Net.Imap.ImapFolder has not been opened.

OperationCanceledException The operation was canceled via the cancellation token.
System.IO.IOException An I/O error occurred.
MailKit.Net.Imap.ImapCommandException The server replied to the IDLE command with a NO or BAD response.
MailKit.Net.Imap.ImapProtocolException The server responded with an unexpected token.

Remarks

When a client enters the IDLE state, the IMAP server will send events to the client as they occur on the selected folder. These events may include notifications of new messages arriving, expunge notifications, flag changes, etc.

Due to the nature of the IDLE command, a folder must be selected before a client can enter into the IDLE state. This can be done by opening a folder using MailKit.MailFolder.Open(MailKit.FolderAccess, System.Threading.CancellationToken) or any of the other variants.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

IdleAsync Method

Asynchronously toggle the MailKit.Net.Imap.ImapClient into the IDLE state.

Syntax

Parameters

doneToken
The cancellation token used to return to the non-idle state.
cancellationToken
The cancellation token.

Returns

An asynchronous task context.

Exceptions

Type Reason
ArgumentException doneToken must be cancellable (i.e. System.Threading.CancellationToken.None cannot be used).
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.
InvalidOperationException

The MailKit.Net.Imap.ImapClient is not connected.

-or-

The MailKit.Net.Imap.ImapClient is not authenticated.

-or-

A MailKit.Net.Imap.ImapFolder has not been opened.

OperationCanceledException The operation was canceled via the cancellation token.
System.IO.IOException An I/O error occurred.
MailKit.Net.Imap.ImapCommandException The server replied to the IDLE command with a NO or BAD response.
MailKit.Net.Imap.ImapProtocolException The server responded with an unexpected token.

Remarks

When a client enters the IDLE state, the IMAP server will send events to the client as they occur on the selected folder. These events may include notifications of new messages arriving, expunge notifications, flag changes, etc.

Due to the nature of the IDLE command, a folder must be selected before a client can enter into the IDLE state. This can be done by opening a folder using MailKit.MailFolder.Open(MailKit.FolderAccess, System.Threading.CancellationToken) or any of the other variants.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

Inbox Property

Get the Inbox folder.

Syntax

public override MailKit.IMailFolder Inbox { get; }

Value

The Inbox folder.

Remarks

The Inbox folder is the default folder and always exists.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

IsConnected Property

Get whether or not the client is currently connected to an IMAP server.

Syntax

public override bool IsConnected { get; }

Value

true if the client is connected; otherwise, false.

Remarks

When an MailKit.Net.Imap.ImapProtocolException is caught, the connection state of the MailKit.Net.Imap.ImapClient should be checked before continuing.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

NoOp Method

Ping the IMAP server to keep the connection alive.

Syntax

public override void NoOp (System.Threading.CancellationToken cancellationToken)

Parameters

cancellationToken
The cancellation token.

Exceptions

Type Reason
ObjectDisposedException The MailKit.Net.Imap.ImapClient has been disposed.
InvalidOperationException

The MailKit.Net.Imap.ImapClient is not connected.

-or-

The MailKit.Net.Imap.ImapClient is not authenticated.

OperationCanceledException The operation was canceled via the cancellation token.
System.IO.IOException An I/O error occurred.
MailKit.Net.Imap.ImapCommandException The server replied to the NOOP command with a NO or BAD response.
MailKit.Net.Imap.ImapProtocolException The server responded with an unexpected token.

Remarks

Mail servers, if left idle for too long, will automatically drop the connection.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

OtherNamespaces Property

Get the other namespaces.

Syntax

public override MailKit.FolderNamespaceCollection OtherNamespaces { get; }

Value

The other namespaces.

Remarks

The other folder namespaces contain other mailbox folders.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

PersonalNamespaces Property

Get the personal namespaces.

Syntax

public override MailKit.FolderNamespaceCollection PersonalNamespaces { get; }

Value

The personal namespaces.

Remarks

The personal folder namespaces contain a user's personal mailbox folders.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

Protocol Property

Get the protocol supported by the message service.

Syntax

protected override string Protocol { get; }

Value

The protocol.

Remarks

Gets the protocol supported by the message service.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

SharedNamespaces Property

Get the shared namespaces.

Syntax

public override MailKit.FolderNamespaceCollection SharedNamespaces { get; }

Value

The shared namespaces.

Remarks

The shared folder namespaces contain mailbox folders that are shared with the user.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

SupportsQuotas Property

Get whether or not the mail store supports quotas.

Syntax

public override bool SupportsQuotas { get; }

Value

true if the mail store supports quotas; otherwise, false.

Remarks

Gets whether or not the mail store supports quotas.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

SyncRoot Property

Gets the lock object used by the default Async methods.

Syntax

public override object SyncRoot { get; }

Value

The lock object.

Remarks

Gets the lock object used by the default Async methods.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

ThreadingAlgorithms Property

Get the threading algorithms supported by the IMAP server.

Syntax

public HashSet<MailKit.ThreadingAlgorithm> ThreadingAlgorithms { get; }

Value

The authentication mechanisms.

Remarks

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0

Timeout Property

Get or set the timeout for network streaming operations, in milliseconds.

Syntax

public override int Timeout { get; set; }

Value

The timeout in milliseconds.

Remarks

Gets or sets the underlying socket stream's System.IO.Stream.ReadTimeout and System.IO.Stream.WriteTimeout values.

Requirements

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll)
Assembly Versions: 0.90.0.0