Click or drag to resize
MimeKit

ImapFolderExpungeAsync(CancellationToken) Method

Asynchronously expunge the folder, permanently removing all messages marked for deletion.

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll) Version: 4.3.0
Syntax
C#
public override Task ExpungeAsync(
	CancellationToken cancellationToken = default
)

Parameters

cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

Task
An asynchronous task context.

Implements

IMailFolderExpungeAsync(CancellationToken)
IMailFolderExpungeAsync(CancellationToken)
Exceptions
ExceptionCondition
ObjectDisposedException The ImapClient has been disposed.
FolderNotOpenException The ImapFolder is not currently open in read-write mode.
ServiceNotConnectedException The ImapClient is not connected.
ServiceNotAuthenticatedException The ImapClient is not authenticated.
OperationCanceledException The operation was canceled via the cancellation token.
IOException An I/O error occurred.
ImapProtocolException The server's response contained unexpected tokens.
ImapCommandException The server replied with a NO or BAD response.
Remarks

The EXPUNGE command permanently removes all messages in the folder that have the Deleted flag set.

For more information about the EXPUNGE command, see rfc3501.

Note  Note
Normally, a MessageExpunged event will be emitted for each message that is expunged. However, if the IMAP server supports the QRESYNC extension and it has been enabled via the EnableQuickResync(CancellationToken) method, then the MessagesVanished event will be emitted rather than the MessageExpunged event.
See Also