public static void Run() { //ExStart:CopyMultipleMessagesFromOneFoldertoAnother using (ImapClient client = new ImapClient("exchange.aspose.com", "username", "password")) { // Create the destination folder string folderName = "EMAILNET-35242"; if (!client.ExistFolder(folderName)) { client.CreateFolder(folderName); } try { // Append a couple of messages to the server MailMessage message1 = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35242 - " + Guid.NewGuid(), "EMAILNET-35242 Improvement of copy method.Add ability to 'copy' multiple messages per invocation."); string uniqueId1 = client.AppendMessage(message1); MailMessage message2 = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35242 - " + Guid.NewGuid(), "EMAILNET-35242 Improvement of copy method.Add ability to 'copy' multiple messages per invocation."); string uniqueId2 = client.AppendMessage(message2); // Verify that the messages have been added to the mailbox client.SelectFolder(ImapFolderInfo.InBox); ImapMessageInfoCollection msgsColl = client.ListMessages(); foreach (ImapMessageInfo msgInfo in msgsColl) { Console.WriteLine(msgInfo.Subject); } // Copy multiple messages using the CopyMessages command and Verify that messages are copied to the destination folder client.CopyMessages(new[] { uniqueId1, uniqueId2 }, folderName); client.SelectFolder(folderName); msgsColl = client.ListMessages(); foreach (ImapMessageInfo msgInfo in msgsColl) { Console.WriteLine(msgInfo.Subject); } } finally { try { client.DeleteFolder(folderName); } catch { } } } //ExEnd:CopyMultipleMessagesFromOneFoldertoAnother }
static void Run() { // ExStart: MoveMessage ///<summary> /// This example shows how to move a message from one folder of a mailbox to another one using the ImapClient API of Aspose.Email for .NET /// Available from Aspose.Email for .NET 6.4.0 onwards /// -------------- Available API Overload Members -------------- /// Void ImapClient.MoveMessage(IConnection iConnection, int sequenceNumber, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(IConnection iConnection, string uniqueId, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(int sequenceNumber, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(string uniqueId, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(IConnection iConnection, int sequenceNumber, string folderName) /// Void ImapClient.MoveMessage(IConnection iConnection, string uniqueId, string folderName) /// Void ImapClient.MoveMessage(int sequenceNumber, string folderName) /// Void ImapClient.MoveMessage(string uniqueId, string folderName) ///</summary> using (ImapClient client = new ImapClient("host.domain.com", 993, "username", "password")) { string folderName = "EMAILNET-35151"; if (!client.ExistFolder(folderName)) { client.CreateFolder(folderName); } try { MailMessage message = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35151 - " + Guid.NewGuid(), "EMAILNET-35151 ImapClient: Provide option to Move Message"); client.SelectFolder(ImapFolderInfo.InBox); // Append the new message to Inbox folder string uniqueId = client.AppendMessage(ImapFolderInfo.InBox, message); ImapMessageInfoCollection messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); // Now move the message to the folder EMAILNET-35151 client.MoveMessage(uniqueId, folderName); client.CommitDeletes(); // Verify that the message was moved to the new folder client.SelectFolder(folderName); messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); // Verify that the message was moved from the Inbox client.SelectFolder(ImapFolderInfo.InBox); messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); } finally { try { client.DeleteFolder(folderName); } catch { } } } // ExEnd: MoveMessage }
static void Run() { // ExStart: MoveMessage ///<summary> /// This example shows how to move a message from one folder of a mailbox to another one using the ImapClient API of Aspose.Email for .NET /// Available from Aspose.Email for .NET 6.4.0 onwards /// -------------- Available API Overload Members -------------- /// Void ImapClient.MoveMessage(IConnection iConnection, int sequenceNumber, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(IConnection iConnection, string uniqueId, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(int sequenceNumber, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(string uniqueId, string folderName, bool commitDeletions) /// Void ImapClient.MoveMessage(IConnection iConnection, int sequenceNumber, string folderName) /// Void ImapClient.MoveMessage(IConnection iConnection, string uniqueId, string folderName) /// Void ImapClient.MoveMessage(int sequenceNumber, string folderName) /// Void ImapClient.MoveMessage(string uniqueId, string folderName) ///</summary> using (ImapClient client = new ImapClient("host.domain.com", 993, "username", "password")) { string folderName = "EMAILNET-35151"; if (!client.ExistFolder(folderName)) client.CreateFolder(folderName); try { MailMessage message = new MailMessage( "*****@*****.**", "*****@*****.**", "EMAILNET-35151 - " + Guid.NewGuid(), "EMAILNET-35151 ImapClient: Provide option to Move Message"); client.SelectFolder(ImapFolderInfo.InBox); // Append the new message to Inbox folder string uniqueId = client.AppendMessage(ImapFolderInfo.InBox, message); ImapMessageInfoCollection messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); // Now move the message to the folder EMAILNET-35151 client.MoveMessage(uniqueId, folderName); client.CommitDeletes(); // Verify that the message was moved to the new folder client.SelectFolder(folderName); messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); // Verify that the message was moved from the Inbox client.SelectFolder(ImapFolderInfo.InBox); messageInfoCol1 = client.ListMessages(); Console.WriteLine(messageInfoCol1.Count); } finally { try { client.DeleteFolder(folderName); } catch { } } } // ExEnd: MoveMessage }