PowerTCP Mail for .NET
Mailboxes Property (Imap)
Example 




Gets a MailboxCollection that contains a model of the server mailboxes.
Syntax
Public ReadOnly Property Mailboxes As MailboxCollection
Dim instance As Imap
Dim value As MailboxCollection
 
value = instance.Mailboxes
public MailboxCollection Mailboxes {get;}
public: __property MailboxCollection* get_Mailboxes();
public:
property MailboxCollection^ Mailboxes {
   MailboxCollection^ get();
}

Property Value

MailboxCollection that contains available mailboxes.
Remarks
The collection is sorted alphabetically, with the delimiter counted as a higher value than any other character. Only top-level mailboxes are included. Automatically populated after authentication.
Example
The following example demonstrates navigating into/selecting the specified subfolder/sub-mailbox.
/// <summary>
/// Navigates into the subfolder/sub-mailbox specified by 'subfolderPath'.
/// </summary>
/// <param name="myImap">A connected and authenticated Imap instance</param>
/// <param name="subfolderPath">Path to the subfolder from root, delimited by '/' in this snippet.</param>
/// <remarks>
/// Imap.Select() may be used to access the path directly, but it will not populate the surrounding mailbox tree.
/// </remarks>
public void NavigateToSubfolder(Imap myImap, string subfolderPath)
{
    //Separate provided path into each subfolder name
    string[] subfolderNameArray = subfolderPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);

    //myImap.Mailboxes will already be populated by myImap.Authenticate(), so set to the first subfolder
    Mailbox currentMailbox = myImap.Mailboxes[subfolderNameArray[0]];

    //Subfolders (currentMailbox.Mailboxes) will not be populated, so start drilling down
    for (int i = 1; i <= subfolderNameArray.Length - 1; i++)
    {
        //If the entire mailbox structure was not populated upon login, refresh it now
        if(!myImap.Session.PopulateMailboxTree)
            currentMailbox.Mailboxes.Refresh();
        currentMailbox = currentMailbox.Mailboxes[subfolderNameArray[i]];
    }

    //Now that the end of the specified path has been reached, select that mailbox
    myImap.SelectedMailbox = currentMailbox;
}
''' <summary>
''' Navigates into the subfolder/sub-mailbox specified by 'subfolderPath'.
''' </summary>
''' <param name="myImap">A connected and authenticated Imap instance</param>
''' <param name="subfolderPath">Path to the subfolder from root, delimited by '/' in this snippet.</param>
''' <remarks>
''' Imap.Select() may be used to access the path directly, but it will not populate the surrounding mailbox tree.
''' </remarks>
Public Sub NavigateToSubfolder(ByVal myImap As Imap, ByVal subfolderPath As String)
    'Separate provided path into each subfolder name
    Dim subfolderNameArray() As String = subfolderPath.Split(New String() { "/" }, StringSplitOptions.RemoveEmptyEntries)

    'myImap.Mailboxes will already be populated by myImap.Authenticate(), so set to the first subfolder
    Dim currentMailbox As Mailbox = myImap.Mailboxes(subfolderNameArray(0))

    'Subfolders (currentMailbox.Mailboxes) will not be populated, so start drilling down
    For i As Integer = 1 To subfolderNameArray.Length - 1
        'If the entire mailbox structure was not populated upon login, refresh it now
        If Not myImap.Session.PopulateMailboxTree Then
            currentMailbox.Mailboxes.Refresh()
        End If
        currentMailbox = currentMailbox.Mailboxes(subfolderNameArray(i))
    Next i

    'Now that the end of the specified path has been reached, select that mailbox
    myImap.SelectedMailbox = currentMailbox
End Sub
See Also

Reference

Imap Class
Imap Members


PowerTCP Mail for .NET Documentation Version 4.3
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic