Imap4Folder.SubFolders Property


Gets the sub-folders of current folder.

[VisualĀ Basic 6.0]
Public Property Get SubFolders() As Variant
[Visual C++]
public: get_SubFolders( VARIANT* pVal );

Property Value

A Imap4Folder array containing the sub-folder of current IMAP4 folder.

Example

[VisualĀ Basic 6.0, VBScript, Visual C++] The following sample demonstrates how to enumerate all folders on IMAP4 folder. To get the full samples of EAGetMail, please refer to Samples section.

[Visual Basic 6.0]
Public Sub ConnectImapServer(ByVal Server As String, _
ByVal User As String, _
ByVal Password As String, _
ByVal SSLConnection As Boolean)

Const MailServerPop3 = 0
Const MailServerImap4 = 1

On Error GoTo ErrorHandle
    Dim oServer As New EAGetMailObjLib.MailServer
    oServer.Server = Server
    oServer.User = User
    oServer.Password = Password
    oServer.SSLConnection = SSLConnection
    oServer.Protocol = MailServerImap4
    If oServer.SSLConnection = True Then
        oServer.Port = 993
    Else
        oServer.Port = 143
    End If
    
    Dim oClient As New EAGetMailObjLib.MailClient
    oClient.LicenseCode = "TryIt"
    
    oClient.Connect oServer
    
    Dim arFolder
    arFolder = oClient.Imap4Folders
     'enumerates all folders on IMAP4 server.
    EnumerateFolder arFolder
    oClient.Logout
    
    Exit Sub
ErrorHandle:
    MsgBox Err.Description
End Sub

Public Sub EnumerateFolder(oFolders)
    Dim i, count As Integer
    count = UBound(oFolders)
    For i = LBound(oFolders) To count
        Dim oFolder As EAGetMailObjLib.Imap4Folder
        Set oFolder = oFolders(i)
        Dim s
        s = "Name: " & oFolder.Name & Chr(13) & Chr(10)
        s = s & "FullPath: " & oFolder.FullPath & Chr(13) & Chr(10)
        s = s & "LocalPath: " & oFolder.LocalPath & Chr(13) & Chr(10)
        s = s & "Flags: " & oFolder.IMAP4FolderFlags & Chr(13) & Chr(10)
        s = s & "Subscribed: " & oFolder.Subscribed & Chr(13) & Chr(10)
        MsgBox s
        EnumerateFolder oFolder.SubFolders
    Next   
End Sub

[VBScript]
Public Sub ConnectImapServer(ByVal Server, _
ByVal User, _
ByVal Password, _
ByVal SSLConnection)

    Const MailServerPop3 = 0
    Const MailServerImap4 = 1

    Dim oServer 
    Set oServer = CreateObject("EAGetMailObj.MailServer")
    oServer.Server = Server
    oServer.User = User
    oServer.Password = Password
    oServer.SSLConnection = SSLConnection
    oServer.Protocol = MailServerImap4
    If oServer.SSLConnection = True Then
        oServer.Port = 993
    Else
        oServer.Port = 143
    End If
    
    Dim oClient
    Set oClient = CreateObject("EAGetMailObj.MailClient")
    oClient.LicenseCode = "TryIt"
    
    oClient.Connect oServer
    
    Dim arFolder
    arFolder = oClient.Imap4Folders
     'enumerates all folders on IMAP4 server.
    EnumerateFolder arFolder
    oClient.Logout
End Sub

Public Sub EnumerateFolder(oFolders)
    Dim i, count
    count = UBound(oFolders)
    For i = LBound(oFolders) To count
        Dim oFolder
        Set oFolder = oFolders(i)
        Dim s
        s = "Name: " & oFolder.Name & Chr(13) & Chr(10)
        s = s & "FullPath: " & oFolder.FullPath & Chr(13) & Chr(10)
        s = s & "LocalPath: " & oFolder.LocalPath & Chr(13) & Chr(10)
        s = s & "Flags: " & oFolder.IMAP4FolderFlags & Chr(13) & Chr(10)
        s = s & "Subscribed: " & oFolder.Subscribed & Chr(13) & Chr(10)
        MsgBox s
        EnumerateFolder oFolder.SubFolders
    Next   
End Sub

[Visual C++]
#include "eagetmailobj.tlh"
using namespace EAGetMailObjLib;

void EnumerateFolder( _variant_t &arFolder )
{
    SAFEARRAY *psa = arFolder.parray;
    LONG UBound = 0, LBound = 0;
    
    SafeArrayGetLBound( psa, 1, &LBound );
    SafeArrayGetUBound( psa, 1, &UBound );
    for( long i = LBound; i <= UBound; i++ )
    {
        _variant_t vt;
        SafeArrayGetElement( psa, &i, &vt );
        IImap4FolderPtr oFolder;
        vt.pdispVal->QueryInterface( __uuidof(IImap4Folder), (void**)&oFolder );
        _tprintf( _T("Name: %s\r\n"), (TCHAR*)oFolder->Name );
        _tprintf( _T("FullPath: %s\r\n"), (TCHAR*)oFolder->FullPath );
        _tprintf( _T("LocalPath: %s\r\n"), (TCHAR*)oFolder->LocalPath );
        _tprintf( _T("Flags: %s\r\n"), (TCHAR*)oFolder->IMAP4FolderFlags );
        
        if( oFolder->Subscribed == VARIANT_TRUE )
            _tprintf( _T("Subscribed: True\r\n\r\n"));
        else
            _tprintf( _T("Subscribed: False\r\n\r\n"));

        _variant_t vtFolders = oFolder->SubFolders;
        EnumerateFolder( vtFolders );
    }
}

void ConnectImap4Server( LPCTSTR lpszServer,
    LPCTSTR lpszUser,
    LPCTSTR lpszPassword,
    VARIANT_BOOL SSLConnection )
{
    ::CoInitialize( NULL );

    const int MailServerPop3 = 0;
    const int MailServerImap4 = 1;

    try
    {
        IMailServerPtr oServer = NULL;
        oServer.CreateInstance("EAGetMailObj.MailServer");
        
        oServer->Server = lpszServer;
        oServer->User = lpszUser;
        oServer->Password = lpszPassword;
        oServer->SSLConnection = SSLConnection;
        oServer->Protocol = MailServerImap4;

        if( SSLConnection == VARIANT_TRUE )
            oServer->Port = 993;
        else
            oServer->Port = 143;

        IMailClientPtr oClient = NULL;
        oClient.CreateInstance("EAGetMailObj.MailClient");
        oClient->LicenseCode = _T("TryIt");
        oClient->Connect( oServer );

        _variant_t vtFolders = oClient->Imap4Folders;
        //enumerates all folders on IMAP4 server.
        EnumerateFolder( vtFolders );

    }
    catch( _com_error &ep )
    {
        ::_tprintf( _T("%s\r\n"), (TCHAR*)ep.Description() );
    }

    ::CoUninitialize();
}