public event AsyncCompletedEventHandler UndeleteMessageCompleted
Connect to an IMAP server and asynchronously undelete messages that were flagged as DELETED (Task-based asynchronous approach).
using System; using ComponentPro.Net.Mail; ... // 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"); // ... // Select 'INBOX' mailbox. client.Select("INBOX"); // ... ImapMessageIdCollection set = new ImapMessageIdCollection(1, 2, 3); // Delete mail messages with sequence numbers 1, 2, and 3. client.DeleteMessage(set); // ... // You have deleted the messages and now you wish to undelete them. // Undelete the messages. await client.UndeleteMessageAsync(set); // ... Console.WriteLine("Messages undeleted successfully."); // Disconnect. client.Disconnect();
Connect to an IMAP server and asynchronously undelete messages that were flagged as DELETED (Event-based asynchronous approach).
using System; using System.ComponentModel; using ComponentPro; using ComponentPro.Net.Mail; ... public void DoUndeleteMessagesAsync() { // 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.UndeleteMessageCompleted += client_UndeleteMessageCompleted; // Select 'INBOX' mailbox. client.Select("INBOX"); // ... ImapMessageIdCollection set = new ImapMessageIdCollection(1, 2, 3); // Delete mail messages with sequence numbers 1, 2, and 3. client.DeleteMessage(set); // ... // You have deleted the messages and now you wish to undelete them. // Undelete the messages. client.UndeleteMessageAsync(set); // ... // Disconnect. client.Disconnect(); } void client_UndeleteMessageCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Error != null) { Console.WriteLine("Error: " + e.Error.ToString()); } else { Console.WriteLine("Messages undeleted successfully."); } }