Click or drag to resize
MimeKit

IImapClientNotifyAsync Method

Asynchronously request the specified notification events from the IMAP server.

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll) Version: 4.3.0
Syntax
C#
Task NotifyAsync(
	bool status,
	IList<ImapEventGroup> eventGroups,
	CancellationToken cancellationToken = default
)

Parameters

status  Boolean
true if the server should immediately notify the client of the selected folder's status; otherwise, false.
eventGroups  IListImapEventGroup
The specific event groups that the client would like to receive notifications for.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

Task
An asynchronous task context.
Exceptions
ExceptionCondition
ArgumentNullExceptioneventGroups is null.
ArgumentExceptioneventGroups is empty.
ObjectDisposedException The ImapClient has been disposed.
ServiceNotConnectedException The ImapClient is not connected.
ServiceNotAuthenticatedException The ImapClient is not authenticated.
InvalidOperationException One or more ImapEventGroup is invalid.
NotSupportedException The IMAP server does not support the NOTIFY extension.
OperationCanceledException The operation was canceled via the cancellation token.
IOException An I/O error occurred.
ImapCommandException The server replied to the NOTIFY command with a NO or BAD response.
ImapProtocolException The server responded with an unexpected token.
Remarks

The NOTIFY command is used to expand which notifications the client wishes to be notified about, including status notifications about folders other than the currently selected folder. It can also be used to automatically FETCH information about new messages that have arrived in the currently selected folder.

This, combined with IdleAsync(CancellationToken, CancellationToken), can be used to get instant notifications for changes to any of the specified folders.

See Also