public event AsyncCompletedEventHandler RenameFolderCompleted
Connect to an IMAP server and asynchronously rename an existing mailbox (Event-based asynchronous approach).
using System; using System.ComponentModel; using ComponentPro; using ComponentPro.Net.Mail; ... // Create a new instance of the Imap class. Imap client = new Imap(); // Connect to the server. await client.ConnectAsync("myserver"); // Or you can specify the IMAP port with // client.Connect("myserver", 143); // Login to the server. await client.AuthenticateAsync("user", "password"); // ... // Select the 'INBOX' folder. await client.SelectAsync("INBOX"); // Delete a mailbox in the current working mailbox. await client.RenameFolderAsync("my folder", "new folder name"); // ... Console.WriteLine("Folder renamed."); // Disconnect. client.Disconnect();
Connect to an IMAP server and asynchronously rename an existing mailbox (Event-based asynchronous approach).
using System; using System.ComponentModel; using ComponentPro; using ComponentPro.Net.Mail; ... public void DoRenameFolderAsync() { // Create a new instance of the Imap class. Imap client = new Imap(); // Connect to the server. client.Connect("myserver"); // Or you can specify the IMAP port with // client.Connect("myserver", 143); // Login to the server. client.Authenticate("user", "password"); // ... // Register an event handler. client.RenameFolderCompleted += client_RenameFolderCompleted; // Select the 'INBOX' folder. client.Select("INBOX"); // Delete a mailbox in the current working mailbox. client.RenameFolderAsync("my folder", "new folder name"); // ... // Disconnect. client.Disconnect(); } void client_RenameFolderCompleted(object sender, AsyncCompletedEventArgs e) { // Imap client = (Imap)sender; if (e.Error != null) { Console.WriteLine("Error: " + e.Error.ToString()); } else Console.WriteLine("Folder renamed."); }