public ArrayList List() { string message; string response; ArrayList retval = new ArrayList(); message = "LIST\r\n"; Write(message); response = Response(); if (response.Substring(0, 3) != "+OK") { throw new Pop3Exception(response); } while (true) { response = Response(); if (response == ".\r\n") { return retval; } else { Pop3Message msg = new Pop3Message(); char[] seps = { ' ' }; string[] values = response.Split(seps); msg.number = Int32.Parse(values[0]); msg.bytes = Int32.Parse(values[1]); msg.retrieved = false; retval.Add(msg); continue; } } }
public Pop3Message Retrieve(Pop3Message rhs) { string message; string response; Pop3Message msg = new Pop3Message(); msg.bytes = rhs.bytes; msg.number = rhs.number; message = "RETR " + rhs.number + "\r\n"; Write(message); response = Response(); if (response.Substring(0, 3) != "+OK") { throw new Pop3Exception(response); } msg.retrieved = true; while (true) { response = Response(); if (response == ".\r\n") { break; } else { msg.message += response; } } return msg; }
public void Delete(Pop3Message rhs) { string message; string response; message = "DELE " + rhs.number + "\r\n"; Write(message); response = Response(); if (response.Substring(0, 3) != "+OK") { throw new Pop3Exception(response); } }