ImapCopyMessages Method (String, Boolean, String, UidPlusResult)
Copies the specified messages from the currently selected folder to the specified folder, and retrieves UIDs assigned to the copied messages in the destination folder.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public bool CopyMessages(
	string messageIndexSet,
	bool indexIsUid,
	string targetFolderName,
	UidPlusResult result
)

Parameters

messageIndexSet
Type: SystemString
A message sequence string containing ordinal message numbers or UIDs. Can be composed manually or using ToString.
indexIsUid
Type: SystemBoolean
If true, messageIndexSet is treated as a sequence of UIDs; otherwise, as a sequence of ordinal message numbers.
targetFolderName
Type: SystemString
The full name of the destination folder.
result
Type: MailBee.ImapMailUidPlusResult
A reference to the UidPlusResult object to be filled with the outcome of the copy operation reported by UIDPLUS enabled server (the outcome includes the UIDs of the source messages being copied, the UIDs assigned to the copied 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.

Return Value

Type: Boolean
true if the messages were copied successfully; otherwise, false.
Exceptions
ExceptionCondition
MailBeeExceptionAn error occurred and ThrowExceptions is true.
Remarks

To learn how to specify a valid message sequence (messageIndexSet value), see DownloadEnvelopes(String, Boolean) topic.

When result is specified and the server supports UIDPLUS extension, CopyMessages(String, Boolean, String, UidPlusResult) method will set the supplied UidPlusResult object properties as below:

PropertyValue
IsValidtrue
IsSupportedtrue
SrcUidsThe UidCollection object containing the UIDs of the messages being copied.
SrcUidStringThe string containing the message sequence of UIDs of the messages being copied.
DestUidsThe UidCollection object containing the UIDs assigned to the copied messages in targetFolderName folder.
DestUidStringThe string containing the message sequence of UIDs assigned to the copied messages in targetFolderName folder.
DestUidValidityThe UIDVALIDITY of the targetFolderName folder.
If UIDPLUS capability is not supported by the server, IsSupported will be set to false.

Examples
This sample copies last 3 messages from the inbox folder to the Sent folder (it's assumed the Sent folder already exists and the inbox contains at least 3 messages). The UIDs assigned to the copied messages in the destination folder are displayed if UIDPLUS capability is supported by the server.
using System;
using MailBee;
using MailBee.ImapMail;

class Sample
{
    static void Main(string[] args)
    {
        Imap imp = new Imap();

        // Connect to the server, login and select inbox.
        imp.Connect("mail.company.com");
        imp.Login("jdoe@company.com", "secret");
        imp.SelectFolder("INBOX");

        // Prepare the object that will receive copying results.
        UidPlusResult res = new UidPlusResult();

        string range = (imp.MessageCount - 2).ToString() + ":*";

        // Copy the messages into "Sent" and fill res with copying results.
        imp.CopyMessages(range, false, "Sent", res);

        if (res.IsSupported)
        {
            Console.WriteLine("UIDs assigned to the copied messages are " +
                res.DestUidString);
        }
        else
        {
            Console.WriteLine("Sorry, UIDPLUS is not supported by the server");
        }

        // Disconnect from the server.
        imp.Disconnect();
    }
}
See Also