ImapClientEnableAsync Method

Asynchronously enable the specified IMAP features.

Definition

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
C#
public Task EnableAsync(
	ImapFeatures features,
	CancellationToken cancellationToken = default
)

Parameters

features  ImapFeatures
The features to enable.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

Task
An asynchronous task context.

Implements

IImapClientEnableAsync(ImapFeatures, CancellationToken)

Remarks

Enables the specified features using the ENABLE command. Multiple features may be enabled at once by combining them, e.g. ImapFeatures.UTF8Accept | ImapFeatures.IMAP4rev2.

Features that have already been enabled are not requested again. If all of the requested features are already enabled, then no command is sent to the server.

This method needs to be called immediately after calling one of the Authenticate methods, before opening any folders.

Exceptions

ArgumentOutOfRangeException features contains unknown feature flags.
ObjectDisposedException The ImapClient has been disposed.
ServiceNotConnectedException The ImapClient is not connected.
ServiceNotAuthenticatedException The ImapClient is not authenticated.
InvalidOperationException Features need to be enabled before selecting a folder.
NotSupportedException The IMAP server does not support one or more of the requested features.
OperationCanceledException The operation was canceled via the cancellation token.
IOException An I/O error occurred.
ImapCommandException The server replied to the ENABLE command with a NO or BAD response.
ImapProtocolException An IMAP protocol error occurred.

See Also