/// <summary> /// Gets messages info. /// </summary> public POP3_MessagesInfo GetMessagesInfo() { if(!m_Connected){ throw new Exception("You must connect first !"); } if(!m_Authenticated){ throw new Exception("You must authenticate first !"); } POP3_MessagesInfo messagesInfo = new POP3_MessagesInfo(); // Before getting list get UIDL list, then we make full message info (UID,Nr,Size). Hashtable uidlList = GetUidlList(); Core.SendLine(m_pSocket,"LIST"); /* NOTE: If reply is +OK, this is multiline respone and is terminated with '.'. Examples: C: LIST S: +OK 2 messages (320 octets) S: 1 120 S: 2 200 S: . ... C: LIST 3 S: -ERR no such message, only 2 messages in maildrop */ // Read first line of reply, check if it's ok string line = Core.ReadLine(m_pSocket); if(line.StartsWith("+OK")){ // Read lines while get only '.' on line itshelf. while(true){ line = Core.ReadLine(m_pSocket); // End of data if(line.Trim() == "."){ break; } else{ string[] param = line.Trim().Split(new char[]{' '}); int nr = Convert.ToInt32(param[0]); long size = Convert.ToInt64(param[1]); messagesInfo.Add(uidlList[nr].ToString(),nr,size); } } } else{ throw new Exception("Server returned:" + line); } return messagesInfo; }
/// <summary> /// Gets messages info. /// </summary> public POP3_MessagesInfo GetMessagesInfo() { if (!m_Connected) { throw new Exception("You must connect first !"); } if (!m_Authenticated) { throw new Exception("You must authenticate first !"); } POP3_MessagesInfo messagesInfo = new POP3_MessagesInfo(); // Before getting list get UIDL list, then we make full message info (UID,Nr,Size). Hashtable uidlList = GetUidlList(); Core.SendLine(m_pSocket, "LIST"); /* NOTE: If reply is +OK, this is multiline respone and is terminated with '.'. * Examples: * C: LIST * S: +OK 2 messages (320 octets) * S: 1 120 * S: 2 200 * S: . * ... * C: LIST 3 * S: -ERR no such message, only 2 messages in maildrop */ // Read first line of reply, check if it's ok string line = Core.ReadLine(m_pSocket); if (line.StartsWith("+OK")) { // Read lines while get only '.' on line itshelf. while (true) { line = Core.ReadLine(m_pSocket); // End of data if (line.Trim() == ".") { break; } else { string[] param = line.Trim().Split(new char[] { ' ' }); int nr = Convert.ToInt32(param[0]); long size = Convert.ToInt64(param[1]); messagesInfo.Add(uidlList[nr].ToString(), nr, size); } } } else { throw new Exception("Server returned:" + line); } return(messagesInfo); }