/// <summary> /// Get a list of message numbers with a unique identifier for each message number. /// </summary> public IEnumerable <PopUid> GetMessageUids() { if (!Connected) { throw new InvalidOperationException("You must be connected."); } List <PopUid> uids = new List <PopUid>(); PopCommandResponse response = SendCommand("UIDL"); if (response.Success) { string line; while (null != (line = StreamReader.ReadLine()) && "." != line) { string[] s = line.Split(' '); if (s.Length > 1) { PopUid uid = new PopUid(); int.TryParse(s[0], out uid.MessageNumber); uid.UniqueIdentifier = s[1]; uids.Add(uid); } } } return(new ReadOnlyCollection <PopUid>(uids)); }
/// <summary> /// Get unique identifier for the given message number. /// </summary> /// <param name="intMessageNumber">message number</param> public PopUid GetMessageUid(int intMessageNumber) { if (!Connected) { throw new InvalidOperationException("You must be connected."); } PopCommandResponse response = SendCommand("UIDL " + intMessageNumber.ToString()); if (response.Success) { if (response.Parameters.Count > 1) { PopUid uid = new PopUid(); int.TryParse(response.Parameters[0], out uid.MessageNumber); uid.UniqueIdentifier = response.Parameters[1]; } } throw new InvalidDataException("Server responded with invalid data: " + response.RawValue); }
/// <summary> /// Get a list of message numbers with a unique identifier for each message number. /// </summary> public IEnumerable<PopUid> GetMessageUids() { if( !Connected ) throw new InvalidOperationException( "You must be connected." ); List<PopUid> uids = new List<PopUid>(); PopCommandResponse response = SendCommand( "UIDL" ); if( response.Success ) { string line; while( null != (line=StreamReader.ReadLine()) && "." != line ) { string[] s = line.Split(' '); if( s.Length > 1 ) { PopUid uid = new PopUid(); int.TryParse( s[0], out uid.MessageNumber ); uid.UniqueIdentifier = s[1]; uids.Add( uid ); } } } return new ReadOnlyCollection<PopUid>( uids ); }
/// <summary> /// Get unique identifier for the given message number. /// </summary> /// <param name="intMessageNumber">message number</param> public PopUid GetMessageUid( int intMessageNumber ) { if( !Connected ) throw new InvalidOperationException( "You must be connected." ); PopCommandResponse response = SendCommand( "UIDL " + intMessageNumber.ToString() ); if( response.Success ) { if( response.Parameters.Count > 1 ) { PopUid uid = new PopUid(); int.TryParse( response.Parameters[0], out uid.MessageNumber ); uid.UniqueIdentifier = response.Parameters[1]; } } throw new InvalidDataException( "Server responded with invalid data: " + response.RawValue ); }