Esempio n. 1
0
    public MailboxCollection ListSuscribesMailboxes(string reference, string pattern) {
        if(!_connected) throw new Exception("You must connect first !");
        if(!_authenticated)throw new Exception("You must authenticate first !");
        MailboxCollection x = new MailboxCollection();
        string command = this.Tag + "LSUB \""+reference+"\" \""+pattern+"\"\r\n";
        SendCommand(command);
		string reg = "\\* LSUB \\(([^\\)]*)\\) \\\"([^\\\"]+)\\\" \\\"([^\\\"]+)\\\"";
        string response = ReadLine();
        Match m = Regex.Match(response,reg);
        while(m.Groups.Count > 1){
            Mailbox mailbox = new Mailbox(m.Groups[3].ToString());
            x.Add(mailbox);
            response = ReadLine();
            m = Regex.Match(response,reg);
        }
        return x;
    }
		public void Add(Mailbox mailbox){
			this.List.Add(mailbox);
		}
Esempio n. 3
0
	public Mailbox SelectMailbox(string mailbox) {
		try {
	        if(!_connected) throw new Exception("You must connect first !");
    	    if(!_authenticated)throw new Exception("You must authenticate first !");
        	Mailbox x = null;
			string tag = this.Tag;
    	    string command = tag + "SELECT \""+mailbox+"\"\r\n";
        	SendCommand(command);
	        string response = ReadLine();
			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 = ReadLine();
        		}
				if(response.StartsWith(tag+"OK")){
					if(response.ToUpper().IndexOf("READ/WRITE") > -1) x.Rw = true;
				}
				this._selected = true;
				this._selectedmailbox = mailbox;
			}
	        return x;
		} catch (Exception e) {
            this._lasterror = "SelectMailbox : " + e.Message;
            return null;
        }
	}
 public void Add(Mailbox mailbox)
 {
     this.List.Add(mailbox);
 }