/// <summary> /// Get the sizes of all the messages. /// </summary> /// <returns>Size of each message</returns> public IEnumerable <PopStat> List() { if (!Connected) { throw new InvalidOperationException("You must be connected."); } List <PopStat> sizes = null; PopCommandResponse response = SendCommand("LIST"); if (response.Success) { sizes = new List <PopStat>(); string line; while (null != (line = StreamReader.ReadLine()) && "." != line) { string[] s = line.Split(' '); if (s.Length > 1) { PopStat stat = new PopStat(); int.TryParse(s[0], out stat.MessageNumber); int.TryParse(s[1], out stat.Size); sizes.Add(stat); } } } return(new ReadOnlyCollection <PopStat>(sizes)); }
/// <summary> /// Get max message number and mailbox size. /// </summary> /// <returns>PopStat object with the max message number and mailbox size.</returns> public PopStat SendStat() { PopCommandResponse response = SendCommand("STAT"); PopStat stat = new PopStat(); IList <int> v = response.IntValues(); if (v.Count > 1) { stat.MessageNumber = v[0]; stat.Size = v[1]; } return(stat); }
/// <summary> /// Get the size of a message /// </summary> /// <param name="intMessageNumber">message number</param> /// <returns>Size of message</returns> public PopStat List(int intMessageNumber) { if (!Connected) { throw new InvalidOperationException("You must be connected."); } PopCommandResponse response = SendCommand("LIST " + intMessageNumber.ToString()); PopStat stat = new PopStat(); IList <int> v = response.IntValues(); stat.MessageNumber = v[0]; stat.Size = v[1]; return(stat); }
/// <summary> /// Get max message number and mailbox size. /// </summary> /// <returns>PopStat object with the max message number and mailbox size.</returns> public PopStat SendStat() { PopCommandResponse response = SendCommand( "STAT" ); PopStat stat = new PopStat(); IList<int> v = response.IntValues(); if( v.Count > 1 ) { stat.MessageNumber = v[0]; stat.Size = v[1]; } return stat; }
/// <summary> /// Get the size of a message /// </summary> /// <param name="intMessageNumber">message number</param> /// <returns>Size of message</returns> public PopStat List(int intMessageNumber) { if( !Connected ) throw new InvalidOperationException( "You must be connected." ); PopCommandResponse response = SendCommand( "LIST " + intMessageNumber.ToString() ); PopStat stat = new PopStat(); IList<int> v = response.IntValues(); stat.MessageNumber = v[0]; stat.Size = v[1]; return stat; }
/// <summary> /// Get the sizes of all the messages. /// </summary> /// <returns>Size of each message</returns> public IEnumerable<PopStat> List() { if( !Connected ) throw new InvalidOperationException( "You must be connected." ); List<PopStat> sizes=null; PopCommandResponse response = SendCommand( "LIST" ); if( response.Success ) { sizes = new List<PopStat>(); string line; while ( null != (line = StreamReader.ReadLine() ) && "." != line ) { string[] s = line.Split( ' ' ); if( s.Length > 1 ) { PopStat stat = new PopStat(); int.TryParse( s[0], out stat.MessageNumber ); int.TryParse( s[1], out stat.Size ); sizes.Add( stat ); } } } return new ReadOnlyCollection<PopStat>(sizes); }