MailClient.Undelete Method

Undelete the email marked as deleted on IMAP4server. POP3/Exchange Web Service/WebDAV protocol doesn't support this method.

[Visual Basic]
Public Sub Undelete( _
    info As MailInfo
public void Undelete(
    MailInfo info
public: void Undelete(
    MailInfo^ info
public function Undelete( 
    info: MailInfo


The MailInfo instance to undelete.


[Visual Basic, C#, C++] The following example demonstrates how to undelete email with EAGetMail POP3 & IMAP Component, but it doesn't demonstrates the events and mail parsing usage. To get the full samples of EAGetMail, please refer to Samples section.

[VB - Undelete emails]
Imports System
Imports System.Globalization
Imports System.IO
Imports System.Text
Imports EAGetMail

Public Class TestClass
    Public Sub UndeleteMail(server As String, user As String, password As String, useSsl As Boolean)

            ' Most modern email server require SSL/TLS connection, 
            ' set useSsl to true Is recommended.
            Dim oServer As New MailServer(server, user, password, useSsl,
                        ServerAuthType.AuthLogin, ServerProtocol.Imap4)

            ' IMAP4 port Is 143,  IMAP4 SSL port Is 993.
            oServer.Port = If(useSsl, 993, 143)

            Console.WriteLine("Connecting server ...")
            Dim oClient As New MailClient("TryIt")

            Console.WriteLine("Retrieving email list ...")
            Dim infos() As MailInfo = oClient.GetMailInfos()

            Console.WriteLine("Total {0} email(s)", infos.Length)

            For i As Integer = 0 To infos.Length - 1
                Dim info As MailInfo = infos(i)
                If info.Deleted Then
                    ' undelete email
                End If

            Console.WriteLine("Disconnecting ...")

        Catch ep As Exception
            Console.WriteLine("Error: {0}", ep.Message)
        End Try

    End Sub
End Class

[C# - Undelete emails] using System; using System.IO; using System.Globalization; using System.Text; using EAGetMail; class TestClass { public void UndeleteMail(string server, string user, string password, bool useSsl) { try { // Most modern email server require SSL/TLS connection, // set useSsl to true is recommended. MailServer oServer = new MailServer(server, user, password, useSsl, ServerAuthType.AuthLogin, ServerProtocol.Imap4); // IMAP4 port is 143, IMAP4 SSL port is 993. oServer.Port = (useSsl) ? 993 : 143; Console.WriteLine("Connecting server ..."); MailClient oClient = new MailClient("TryIt"); oClient.Connect(oServer); Console.WriteLine("Retreiving email list ..."); MailInfo[] infos = oClient.GetMailInfos(); Console.WriteLine("Total {0} email(s)", infos.Length); for (int i = 0; i < infos.Length; i++) { MailInfo info = infos[i]; if(info.Deleted) { // Undelete email oClient.Undelete(info); } } Console.WriteLine("Disconnecting ..."); oClient.Logout(); Console.WriteLine("Completed!"); } catch (Exception ep) { Console.WriteLine("Error: {0}", ep.Message); } } }
[C++/CLI - Undelete emails] using namespace System; using namespace System::Globalization; using namespace System::IO; using namespace EAGetMail; //add EAGetMail namespace void ExpungeMail(String ^server, String ^user, String ^password, bool useSsl) { try { // Most modern email server require SSL/TLS connection, // set useSsl to true is recommended. MailServer ^oServer = gcnew MailServer(server, user, password, useSsl, ServerAuthType::AuthLogin, ServerProtocol::Imap4); // IMAP4 port is 143, IMAP4 SSL port is 993. oServer->Port = (useSsl) ? 993 : 143; Console::WriteLine("Connecting server ..."); MailClient ^oClient = gcnew MailClient("TryIt"); oClient->Connect(oServer); Console::WriteLine("Retreiving email list ..."); array<MailInfo^>^infos = oClient->GetMailInfos(); Console::WriteLine("Total {0} email(s)", infos->Length); for (int i = 0; i < infos->Length; i++) { MailInfo ^info = infos[i]; if(info->Deleted) { // Undelete email oClient->Undelete(info, false); } } Console::WriteLine("Disconnecting ..."); oClient->Logout(); Console::WriteLine("Completed!"); } catch (Exception ^ep) { Console::WriteLine("Error: {0}", ep->Message); } }

See Also

MailClient.Delete Method
MailClient.Reset Method