Imap |
public override void Expunge( IList<UniqueId> uids, CancellationToken cancellationToken = default )
Exception | Condition |
---|---|
ArgumentNullException | uids is null. |
ArgumentException | One or more of the uids is invalid. |
ObjectDisposedException | The ImapClient has been disposed. |
ServiceNotConnectedException | The ImapClient is not connected. |
ServiceNotAuthenticatedException | The ImapClient is not authenticated. |
FolderNotOpenException | The ImapFolder is not currently open in read-write mode. |
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. |
Expunges the specified uids, permanently removing them from the folder.
If the IMAP server supports the UIDPLUS extension (check the Capabilities for the UidPlus flag), then this operation is atomic. Otherwise, MailKit implements this operation by first searching for the full list of message uids in the folder that are marked for deletion, unmarking the set of message uids that are not within the specified list of uids to be be expunged, expunging the folder (thus expunging the requested uids), and finally restoring the deleted flag on the collection of message uids that were originally marked for deletion that were not included in the list of uids provided. For this reason, it is advisable for clients that wish to maintain state to implement this themselves when the IMAP server does not support the UIDPLUS extension.
For more information about the UID EXPUNGE command, see rfc4315.
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. |