Dart.Mail Namespace > Mailbox Class : Mailboxes Property |
Public ReadOnly Property Mailboxes As MailboxCollection
Dim instance As Mailbox Dim value As MailboxCollection value = instance.Mailboxes
public MailboxCollection Mailboxes {get;}
public: __property MailboxCollection* get_Mailboxes();
public: property MailboxCollection^ Mailboxes { MailboxCollection^ get(); }
Returns a MailboxCollection containing mailboxes falling directly below this mailbox in the hierarchy. MailboxCollection.Refresh must be used to populate this collection before it can be accessed if ImapSession.PopulateMailboxTree is false, or if the desired mailbox was added/renamed by another client since the contents were last updated.
/// <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