ImapBeginCopyOrMoveMessages Method

Note: This API is now obsolete.

Begins an asynchronous request for copying or moving the specified messages from the currently selected folder to the specified folder.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use CopyMessagesAsync or MoveMessagesAsync instead.")]
public IAsyncResult BeginCopyOrMoveMessages(
	string messageIndexSet,
	bool indexIsUid,
	string targetFolderName,
	UidPlusResult result,
	bool move,
	AsyncCallback callback,
	Object state


Type: SystemString
A message sequence string containing ordinal message numbers or UIDs. Can be composed manually or using ToString.
Type: SystemBoolean
If true, messageIndexSet is treated as a sequence of UIDs; otherwise, as a sequence of ordinal message numbers.
Type: SystemString
The full name of the destination folder.
Type: MailBee.ImapMailUidPlusResult
A reference to the UidPlusResult object to be filled with the outcome of the copy/move operation reported by UIDPLUS enabled server (the outcome includes the UIDs of the source messages being copied/moved, the UIDs assigned to the copied/moved messages in the destination folder, and the UIDVALIDITY of the destination folder), or a null reference (Nothing in Visual Basic) if the application does not need this information.
Type: SystemBoolean
If true, the messages will be moved; otherwise, copied.
Type: SystemAsyncCallback
The AsyncCallback delegate. You can leave it a null reference (Nothing in Visual Basic) if you do not use callbacks.
Type: SystemObject
An object that contains state information for this request. You can leave it a null reference (Nothing in Visual Basic).

Return Value

Type: IAsyncResult
An IAsyncResult that references the asynchronous copying or moving messages process.
MailBeeInvalidStateExceptionThere is already an operation in progress.
This method is an asynchronous version of CopyMessages(String, Boolean, String, UidPlusResult) (if move is false) or MoveMessages(String, Boolean, String, UidPlusResult) (if move is true).

This console sample demonstrates asynchronous moving the first and the last messages from the Inbox folder into the Trash folder. A callback function is used as well.

The sample assumes "Trash" folder had already been created in the past. To learn how to make sure the folder exists, see UploadMessage(MailMessage, String, String, DateTime) or UploadMessage(MailMessage, String, String, String) samples.

using System;
using MailBee;
using MailBee.ImapMail;

class Sample
    // A callback function.
    private static void CopyOrMoveMessagesCallback(IAsyncResult result)
        Imap imp = (Imap)result.AsyncState;
            Console.WriteLine("The messages moved successfully");
        catch (MailBeeException e)
            // In callback functions (generally speaking, in worker threads),
            // it's better to handle exceptions. If exception is not handled,
            // the worker thread silently dies and the application may never
            // know that something went wrong.

    // The actual code.
    static void Main(string[] args)
        Imap imp = new Imap();

        // Connect to the server, login and select inbox.
        imp.Login("jdoe", "secret");

        // Initiate an asynchronous messages moving attempt.
        // We move the first and the last messages.
        IAsyncResult ar = imp.BeginCopyOrMoveMessages(
            "1," + imp.MessageCount.ToString(), false,
            "Trash", null, true,
            new AsyncCallback(CopyOrMoveMessagesCallback), imp);

        // Simulate some lengthy work here. At the same time,
        // messages are moved on another thread.

        // If the messages moving attempt is still in progress,
        // then wait until it's finished.
        while (imp.IsBusy) ar.AsyncWaitHandle.WaitOne();

        // Disconnect from the server.
See Also