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.
true if the messages were copied successfully; otherwise, false.
To learn how to specify a valid message sequence (messageIndexSet value), see DownloadEnvelopes topic.
When result is specified and the server supports UIDPLUS extension, CopyMessages method will set the supplied UidPlusResult object properties as below:
| Property | Value |
|---|---|
| IsSupported | true |
| SrcUids | The UidCollection object containing the UIDs of the messages being copied. |
| SrcUidString | The string containing the message sequence of UIDs of the messages being copied. |
| DestUids | The UidCollection object containing the UIDs assigned to the copied messages in targetFolderName folder. |
| DestUidString | The string containing the message sequence of UIDs assigned to the copied messages in targetFolderName folder. |
| DestUidValidity | The UIDVALIDITY of the targetFolderName folder. |
| Exception Type | Condition |
|---|---|
| MailBeeException | An error occurred and ThrowExceptions is true. |
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.
[C#] 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(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.ImapMail Module Sample Sub Main(ByVal args As String()) Dim imp As 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. Dim res As New UidPlusResult Dim range As String = (imp.MessageCount - 2).ToString() & ":*" ' Copy the messages into "Sent" and fill res with copying results. imp.CopyMessages(range, False, "Sent", res) If res.IsSupported Then Console.WriteLine("UIDs assigned to the copied messages are " & _ res.DestUidString) Else Console.WriteLine("Sorry, UIDPLUS is not supported by the server") End If ' Disconnect from the server. imp.Disconnect() End Sub End Module
Imap Class | MailBee.ImapMail Namespace | Imap.CopyMessages Overload List | MoveMessages