ComponentPro UltimateMail

      UndeleteMessageAsync(ImapMessageIdCollection) Method

      See AlsoMembers Options: Show AllLanguage Filter: AllSend comments on this topic to ComponentPro
      Asynchronously marks messages that belong to a specified message set as not deleted. It has no effect on messages were purged using the Purge method.

      Syntax

      public ExtendedAsyncResult UndeleteMessageAsync(
         ImapMessageIdCollection messageSet
      )

      Parameters

      messageSet
      A set of messages.

      Return Value

      An object that references the asynchronous operation.

      Examples

      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.");
          }
      }

      Framework

      .NET Compact Framework.NET Compact Framework

      Supported version: 2.0, 3.5, and 3.9
      Assembly: ComponentPro.Mail.CF (in ComponentPro.Mail.CF.dll)

      .NET Framework.NET Framework

      Supported version: 2.0, 3.0, 3.5, 4.0, 4.5.x, 4.6.x and later
      Assembly: ComponentPro.Mail (in ComponentPro.Mail.dll)

      See Also