Beispiel #1
0
                public ArrayList List()
                {
                    try {
                        string message;
                        string response;

                        var 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 {
                                var 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;
                            }
                        }
                    }
                    catch (Exception e) {
                        //Console.WriteLine(e.Message);
                        Debug.Print(e.Message);
                        return null;
                    }
                }
Beispiel #2
0
                public Pop3Message Retrieve(Pop3Message rhs)
                {
                    try {
                        string message;
                        string response;

                        var 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;
                    }
                    catch (Exception e) {
                        //Console.WriteLine(e.Message);
                        Debug.Print(e.Message);
                        return null;
                    }
                }
Beispiel #3
0
                public void Delete(Pop3Message rhs)
                {
                    try {
                        string message;
                        string response;

                        message = "DELE " + rhs.Number + "\r\n";
                        Write(message);
                        response = Response();
                        if (response.Substring(0, 3) != "+OK") {
                            throw new Pop3Exception(response);
                        }
                    }
                    catch (Exception e) {
                        //Console.WriteLine(e.Message);
                        Debug.Print(e.Message);
                    }
                }