MailClient.UnsubscribeFolder Method


Unsubscribes an IMAP4 folder.

[Visual Basic]
Public Sub UnsubscribeFolder( _
    folder As Imap4Folder _
)
[C#]
public void UnsubscribeFolder(
    Imap4Folder folder
);
[C++]
public: Void UnsubscribeFolder(
    Imap4Folder* folder
);
[JScript]
public function UnsubscribeFolder( 
    folder: Imap4Folder
);

Parameters

folder
the folder instance to unsubscribe.

Remarks

In convention, the IMAP4 client such as outlook express only displays the subscribed folders, you can also use MailClient.SubscribeFolder and MailClient.UnsubscribeFolder method to change the property.

Example

[Visual Basic, C#, C++] The following example demonstrates how to create, subscribe, unsubscribe and delete "TestFolder" with EAGetMail POP3 & IMAP Component. To get the full samples of EAGetMail, please refer to Samples section.

[Visual Basic]
Imports EAGetMail

Sub CreateDeleteMailBox( _
ByVal server As String, _
ByVal user As String, _
ByVal password As String)
    Try
        Dim oClient As New MailClient("TryIt")
        Dim oServer As New MailServer(server, user, password, ServerProtocol.Imap4)
        oClient.Connect(oServer)
        Dim folder As Imap4Folder = oClient.CreateFolder(Nothing, "TestFolder")
        If Not folder.Subscribed Then
            oClient.SubscribeFolder(folder)
        End If

        Dim folders() As Imap4Folder = oClient.Imap4Folders
        Dim count As Integer = folders.Length
        For i As Integer = 0 To count - 1
            Dim fd As Imap4Folder = folders(i)
            Console.WriteLine("folder: {0}", fd.FullPath)
        Next

        oClient.UnsubscribeFolder(folder)
        oClient.DeleteFolder(folder)

        oClient.Logout()
    Catch ep As Exception
        Console.WriteLine(ep.Message)
    End Try
End Sub

[C#]
using System;
using System.Collections;
using EAGetMail;

public static void CreateDeleteMailBox(
    string server,
    string user,
    string password )
{
    try
    {
        MailClient oClient = new MailClient("TryIt");
        MailServer oServer = new MailServer( server, user, password, ServerProtocol.Imap4 );
        oClient.Connect( oServer );
        Imap4Folder folder = oClient.CreateFolder( null, "TestFolder" );
        if( !folder.Subscribed )
            oClient.SubscribeFolder( folder );

        Imap4Folder [] folders = oClient.Imap4Folders;
        int count = folders.Length;
        for( int i = 0; i < count; i++ )
        {
            Imap4Folder fd = folders[i];
            Console.WriteLine( "folder: {0}", fd.FullPath );
        }

        oClient.UnsubscribeFolder( folder );
        oClient.DeleteFolder( folder );
        oClient.Logout();           
    }
    catch( Exception ep )
    {
        Console.WriteLine( ep.Message );
    }       
}

[C++]
using namespace System;
using namespace System::Collections;
using namespace EAGetMail; 

Void CreateDeleteMailBox(
   String* server,
   String* user,
   String* password )
{
    try
    {
        MailClient *oClient = new MailClient(S"TryIt");
        MailServer *oServer = new MailServer( server, user, password, ServerProtocol::Imap4 );

        oClient->Connect( oServer );
        Imap4Folder *folder = oClient->CreateFolder( NULL, S"TestFolder" );
        if(!folder->Subscribed )
            oClient->SubscribeFolder( folder );

        Imap4Folder *folders [] = oClient->Imap4Folders;
        int count = folders->Length;
        for( int i = 0; i < count; i++ )
        {
            Imap4Folder *fd = folders[i];
            Console::WriteLine( S"folder: {0}", fd->FullPath );
        }

        oClient->UnsubscribeFolder( folder );
        oClient->DeleteFolder( folder );
        oClient->Logout();
    }
    catch( Exception *ep )
    {
        Console::WriteLine( ep->Message );
    }
}