Exemple #1
0
        public Mailbox[] ListSuscribesMailboxes(string reference, string pattern)
        {
            IdlePause();

              var x = new List<Mailbox>();
              string command = GetTag() + "LSUB " + reference.QuoteString() + " " + pattern.QuoteString();
              string reg = "\\* LSUB \\(([^\\)]*)\\) \\\"([^\\\"]+)\\\" \\\"([^\\\"]+)\\\"";
              string response = SendCommandGetResponse(command);
              Match m = Regex.Match(response, reg);
              while (m.Groups.Count > 1) {
            Mailbox mailbox = new Mailbox(m.Groups[3].ToString());
            x.Add(mailbox);
            response = GetResponse();
            m = Regex.Match(response, reg);
              }
              IdleResume();
              return x.ToArray();
        }
Exemple #2
0
        public Mailbox SelectMailbox(string mailbox)
        {
            IdlePause();

              Mailbox x = null;
              string tag = GetTag();
              string command = tag + "SELECT " + mailbox.QuoteString();
              string response = SendCommandGetResponse(command);
              if (response.StartsWith("*")) {
            x = new Mailbox(mailbox);
            while (response.StartsWith("*")) {
              Match m;
              m = Regex.Match(response, @"(\d+) EXISTS");
              if (m.Groups.Count > 1) { x.NumMsg = Convert.ToInt32(m.Groups[1].ToString()); }
              m = Regex.Match(response, @"(\d+) RECENT");
              if (m.Groups.Count > 1)
            x.NumNewMsg = Convert.ToInt32(m.Groups[1].ToString());
              m = Regex.Match(response, @"UNSEEN (\d+)");
              if (m.Groups.Count > 1)
            x.NumUnSeen = Convert.ToInt32(m.Groups[1].ToString());
              m = Regex.Match(response, @" FLAGS \((.*?)\)");
              if (m.Groups.Count > 1)
            x.SetFlags(m.Groups[1].ToString());
              response = GetResponse();
            }
            if (IsResultOK(response)) {
              x.IsWritable = Regex.IsMatch(response, "READ.WRITE", RegexOptions.IgnoreCase);
            }
            _SelectedMailbox = mailbox;
              } else {
            throw new Exception(response);
              }
              IdleResume();
              return x;
        }
Exemple #3
0
        public Mailbox Examine(string mailbox)
        {
            IdlePause();

              Mailbox x = null;
              string tag = GetTag();
              string command = tag + "EXAMINE " + mailbox.QuoteString();
              string response = SendCommandGetResponse(command);
              if (response.StartsWith("*")) {
            x = new Mailbox(mailbox);
            while (response.StartsWith("*")) {
              Match m;
              m = Regex.Match(response, @"(\d+) EXISTS");
              if (m.Groups.Count > 1) { x.NumMsg = Convert.ToInt32(m.Groups[1].ToString()); }
              m = Regex.Match(response, @"(\d+) RECENT");
              if (m.Groups.Count > 1)
            x.NumNewMsg = Convert.ToInt32(m.Groups[1].ToString());
              m = Regex.Match(response, @"UNSEEN (\d+)");
              if (m.Groups.Count > 1)
            x.NumUnSeen = Convert.ToInt32(m.Groups[1].ToString());
              m = Regex.Match(response, @" FLAGS \((.*?)\)");
              if (m.Groups.Count > 1)
            x.SetFlags(m.Groups[1].ToString());
              response = GetResponse();
            }
            _SelectedMailbox = mailbox;
              }
              IdleResume();
              return x;
        }