/// <summary> /// Get a unique ID for a single message.<br/> /// </summary> /// <param name="messageNumber"> /// Message number, which may not be marked as deleted.<br/> /// The <paramref name="messageNumber"/> must be inside the range [1, messageCount] /// </param> /// <returns>The unique ID for the message</returns> /// <exception cref="PopServerException">If the server did not accept the UIDL command. This could happen if the <paramref name="messageNumber"/> does not exist</exception> public string GetMessageUid(int messageNumber) { AssertDisposed(); ValidateMessageNumber(messageNumber); if (State != ConnectionState.Transaction) { throw new InvalidUseException("Cannot get message ID, when the user has not been authenticated yet"); } // Example from RFC: //C: UIDL 2 //S: +OK 2 QhdPYR:00WBw1Ph7x7 SendCommand("UIDL " + messageNumber); // Parse out the unique ID return(LastServerResponse.Split(' ')[2]); }
/// <summary> /// Sends a command to the POP server, expects an integer reply in the response /// </summary> /// <param name="command">command to send to server</param> /// <param name="location"> /// The location of the int to return.<br/> /// Example:<br/> /// <c>S: +OK 2 200</c><br/> /// Set <paramref name="location"/>=1 to get 2<br/> /// Set <paramref name="location"/>=2 to get 200<br/> /// </param> /// <returns>Integer value in the reply</returns> /// <exception cref="PopServerException">If the server did not accept the command</exception> private int SendCommandIntResponse(string command, int location) { SendCommand(command); return(int.Parse(LastServerResponse.Split(' ')[location], CultureInfo.InvariantCulture)); }