Imap4Folder.Subscribed Property


Gets whether the IMAP4 folder has been subscribed. For Exchange Web Service/WebDAV protocol, this property always returns false.

[Visual Basic]
Public Property Subscribed As Boolean
[C#]
public bool Subscribed {get; }
[C++]
public: __property bool get_Subscribed();
[JScript]
public function get Subscribed() : Boolean;

Property Value

A bool value indicating whether the IMAP4 folder has been subscribed. 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 sample demonstrates how to enumerate all folders on IMAP4/MS Exchange server. To get the full samples of EAGetMail, please refer to Samples section.

[Visual Basic - Enumerate Mail Folders]
Imports EAGetMail

Public Sub ConnectImap4Server( _
ByVal server As String, _
ByVal user As String, _
ByVal password As String, _
ByVal sslConnection As Boolean)

    
    ' To manage folder with Exchange Web Service, please change
    ' ServerProtocol.Imap4 to ServerProtocol.ExchangeEWS to MailServer constructor
    ' and also set sslConnection to True

    ' To manage folder with Exchange WebDAV, please change
    ' ServerProtocol.Imap4 to ServerProtocol.ExchangeWebDAV to MailServer constructor

    ' Exchange Server supports IMAP4 protocol as well, but in Exchange 2007
    ' or later version, IMAP4 service is disabled by default. If you don't want to use IMAP4
    ' to manage folder from Exchange Server, you can use Exchange Web Service (Exchange 2007/2010 or
    ' later version) or WebDAV (Exchange 2000/2003) protocol.
    
    
    Try
        Dim oServer As New MailServer(server, user, password, sslConnection, _
            ServerAuthType.AuthLogin, ServerProtocol.Imap4)

        Dim oClient As New MailClient("TryIt")
        oClient.Connect(oServer)

        Dim folders() As Imap4Folder = oClient.Imap4Folders
        ' enumerates all folders on IMAP4/Exchange server.
        EnumerateFolder(folders)

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

Public Sub EnumerateFolder(ByVal folders() As Imap4Folder)
    For i As Integer = 0 To folders.Length - 1
        Dim folder As Imap4Folder = folders(i)
        
        Console.WriteLine("Name: {0}", folder.Name)
        Console.WriteLine("FullPath: {0}", folder.FullPath)
        Console.WriteLine("LocalPath: {0}", folder.LocalPath)
        Console.WriteLine("Flags: {0}", folder.IMAP4FolderFlags)
        Console.WriteLine("Subscribed: {0}" & vbCrLf, folder.Subscribed)

        EnumerateFolder(folder.SubFolders)
    Next
End Sub


[C# - Enumerate Mail Folders] using System; using EAGetMail; public static void ConnectImap4Server( string server, string user, string password, bool sslConnection) { // To manage folder with Exchange Web Service, please change // ServerProtocol.Imap4 to ServerProtocol.ExchangeEWS to MailServer constructor // and also set sslConnection to true // To manage folder with Exchange WebDAV, please change // ServerProtocol.Imap4 to ServerProtocol.ExchangeWebDAV to MailServer constructor // Exchange Server supports IMAP4 protocol as well, but in Exchange 2007 // or later version, IMAP4 service is disabled by default. If you don't want to use IMAP4 // to manage folder from Exchange Server, you can use Exchange Web Service (Exchange 2007/2010 or // later version) or WebDAV (Exchange 2000/2003) protocol. try { MailServer oServer = new MailServer(server, user, password, sslConnection, ServerAuthType.AuthLogin, ServerProtocol.Imap4); MailClient oClient = new MailClient("TryIt"); oClient.Connect(oServer); Imap4Folder [] folders = oClient.Imap4Folders; // enumerates all folders on IMAP4 server. EnumerateFolder(folders); oClient.Logout(); } catch(Exception ep) { oClient.Close(); Console.WriteLine(ep.Message); } } public static void EnumerateFolder( Imap4Folder[] folders) { for(int i = 0; i < folders.Length; i++) { Imap4Folder folder = folders[i]; Console.WriteLine("Name: {0}", folder.Name); Console.WriteLine("FullPath: {0}", folder.FullPath); Console.WriteLine("LocalPath: {0}", folder.LocalPath); Console.WriteLine("Flags: {0}", folder.IMAP4FolderFlags); Console.WriteLine("Subscribed: {0}\r\n", folder.Subscribed); EnumerateFolder(folder.SubFolders); } }
[C++/CLI - Enumerate Mail Folders] using namespace System; using namespace EAGetMail; Void EnumerateFolder( array<Imap4Folder^>^folders) { for(int i = 0; i < folders->Length; i++) { Imap4Folder ^folder = folders[i]; Console::WriteLine("Name: {0}", folder->Name); Console::WriteLine("FullPath: {0}", folder->FullPath); Console::WriteLine("LocalPath: {0}", folder->LocalPath); Console::WriteLine("Flags: {0}", folder->IMAP4FolderFlags); Console::WriteLine("Subscribed: {0}\r\n", folder->Subscribed); EnumerateFolder(folder->SubFolders); } } Void ConnectImap4Server( String^ server, String^ user, String^ password, bool sslConnection) { // To manage folder with Exchange Web Service, please change // ServerProtocol::Imap4 to ServerProtocol::ExchangeEWS to MailServer constructor // and also set sslConnection to true // To manage folder with Exchange WebDAV, please change // ServerProtocol::Imap4 to ServerProtocol::ExchangeWebDAV to MailServer constructor // Exchange Server supports IMAP4 protocol as well, but in Exchange 2007 // or later version, IMAP4 service is disabled by default. If you don't want to use IMAP4 // to manage folder from Exchange Server, you can use Exchange Web Service (Exchange 2007/2010 or // later version) or WebDAV (Exchange 2000/2003) protocol. try { MailServer ^oServer = gcnew MailServer(server, user, password, sslConnection, ServerAuthType::AuthLogin, ServerProtocol::Imap4); MailClient ^oClient = gcnew MailClient("TryIt"); oClient->Connect(oServer); array<Imap4Folder^>^folders = oClient->Imap4Folders; //enumerates all folders on IMAP4/Exchange server. EnumerateFolder(folders); oClient->Logout(); } catch(Exception ^ep) { oClient->Close(); Console::WriteLine(ep->Message); } }

See Also

MailClient.Imap4Folders Property
MailClient.CreateFolder Method
MailClient.DeleteFolder Method
MailClient.Move Method
MailClient.Copy Method
MailClient.SelectFolder Method

Online Tutorials

Manage Mail Folders in C#
Manage Mail Folders in VB
Manage Mail Folders in C++/CLI