ImapFolderMoveToAsync(IListInt32, IMoveRequest, CancellationToken) Method

Asynchronously move the specified messages to the destination folder.

Definition

Namespace: MailKit.Net.Imap
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
C#
public override Task MoveToAsync(
	IList<int> indexes,
	IMoveRequest request,
	CancellationToken cancellationToken = default
)

Parameters

indexes  IListInt32
The indexes of the messages to move.
request  IMoveRequest
The move request.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

Task
An awaitable task.

Implements

IMailFolderMoveToAsync(IListInt32, IMoveRequest, CancellationToken)
IMailFolderMoveToAsync(IListInt32, IMoveRequest, CancellationToken)

Remarks

If the IMAP server supports the MOVE command, then the MOVE command will be used. Otherwise, the messages will first be copied to the destination folder and then marked as \Deleted in the originating folder. Since the server could disconnect at any point between those 2 operations, it may be advisable to implement your own logic for moving messages in this case in order to better handle spontaneous server disconnects and other error conditions.

Exceptions

ArgumentNullException

indexes is .

-or-

request is .

ArgumentException

One or more of the indexes is invalid.

-or-

The Destination folder does not belong to the ImapClient.

ObjectDisposedException The ImapClient has been disposed.
ServiceNotConnectedException The ImapClient is not connected.
ServiceNotAuthenticatedException The ImapClient is not authenticated.
FolderNotFoundException The Destination folder does not exist.
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.

See Also