示例#1
0
 /// <summary>
 /// Retrieves a list of mailboxes.
 /// </summary>
 /// <param name="reference">The base path.</param>
 /// <param name="mailboxName">Mailbox name.</param>
 /// <returns>A MailboxCollection object containing the requested mailboxes.</returns>
 /// <example>
 /// <code>
 /// C#
 /// 
 /// Imap4Client imap = new Imap4Client();
 /// imap.Connect("mail.myhost.com");
 /// imap.Login("user","pass");
 /// //Return all children mailboxes of "inbox".
 /// MailboxCollection mailboxes = imap.GetMailboxes("inbox","*");
 /// imap.Disconnect();
 /// 
 /// VB.NET
 /// 
 /// Dim imap As New Imap4Client
 /// imap.Connect("mail.myhost.com")
 /// imap.Login("user","pass")
 /// 'Return all children mailboxes of "inbox".
 /// Dim mailboxes As MailboxCollection = imap.GetMailboxes("inbox","*")
 /// imap.Disconnect()
 /// 
 /// JScript.NET
 /// 
 /// var imap:Imap4Client = new Imap4Client();
 /// imap.Connect("mail.myhost.com");
 /// imap.Login("user","pass");
 /// //Return all children mailboxes of "inbox".
 /// var mailboxes:MailboxCollection  = imap.GetMailboxes("inbox","*");
 /// imap.Disconnect();
 /// </code>
 /// </example>
 public MailboxCollection GetMailboxes(string reference, string mailboxName)
 {
     MailboxCollection mailboxes = new MailboxCollection();
     string response = this.Command("list \"" + reference + "\" \"" + mailboxName + "\"");
     string[] t = System.Text.RegularExpressions.Regex.Split(response, "\r\n");
     string box = "";
     for (int i = 0; i < t.Length - 2; i++)
     {
         try
         {
             box = t[i].Substring(t[i].IndexOf("\" ") + 1).Trim(new char[] {' ', '\"'});
             if (box != reference && reference.ToLower() != (box.ToLower() + "/"))
                 mailboxes.Add(this.ExamineMailbox(box));
         }
         catch
         {
             continue;
         }
     }
     return mailboxes;
 }
示例#2
0
        // Region for Mailboxes folders.
        #region MailBoxes

        /// <summary>
        /// Get all mailbox folders.
        /// </summary>
        /// <returns></returns>
        public MailboxCollection GetAllMailbox()
        {
            AccountSettings.AccountInfo accountInfo = this.GetDefaultAccountInfo();
            MailboxCollection ret = new MailboxCollection();

            if (accountInfo != null)
            {
                if (accountInfo.MailAccountType == AccountType.POP3)
                {
                    // TODO... check if it's possible.
                    //ret = this._pop3Controller.();
                }
                else if (accountInfo.MailAccountType == AccountType.IMAP)
                {
                    ret = this._imap4Controller.GetAllMailbox(Constants.Inbox);
                }
            }
            return ret;
        }