为什么client.GetMessage介于两者之间?

时间:2015-02-17 17:03:05

标签: c# pop3 openpop

我正在尝试从pop服务器下载看不见的电子邮件。我正在尝试此代码(从openPop.net的官方网站复制)

public static List<OpenPop.Mime.Message> FetchUnseenMessages(string hostname, int port, bool useSsl, string username, string password, List<string> seenUids)
        {
            // The client disconnects from the server when being disposed
            using (Pop3Client client = new Pop3Client())
            {
                // Connect to the server
                client.Connect(hostname, port, useSsl);

                // Authenticate ourselves towards the server
                client.Authenticate(username, password,AuthenticationMethod.UsernameAndPassword);

                // Fetch all the current uids seen
                List<string> uids = client.GetMessageUids();

                // Create a list we can return with all new messages
                List<OpenPop.Mime.Message> newMessages = new List<OpenPop.Mime.Message>();

                // All the new messages not seen by the POP3 client
                for (int i = 0; i < uids.Count; i++)
                {
                    string currentUidOnServer = uids[i];
                    if (!seenUids.Contains(currentUidOnServer))
                    {
                        // We have not seen this message before.
                        // Download it and add this new uid to seen uids

                        // the uids list is in messageNumber order - meaning that the first
                        // uid in the list has messageNumber of 1, and the second has 
                        // messageNumber 2. Therefore we can fetch the message using
                        // i + 1 since messageNumber should be in range [1, messageCount]
                        OpenPop.Mime.Message unseenMessage = client.GetMessage(i + 1);

                        // Add the message to the new messages
                        newMessages.Add(unseenMessage);

                        // Add the uid to the seen uids, as it has now been seen
                        seenUids.Add(currentUidOnServer);
                    }
                }

                // Return our new found messages
                //client.Disconnect();
                return newMessages;
            }
        }

当我调试此代码时,我发现代码停止在

OpenPop.Mime.Message unseenMessage = client.GetMessage(i + 1);

之后没有调试按钮工作。即使我按F10,它也什么也没做 如果我不调试代码让应用程序运行然后它继续运行,永远不会出现循环 我在这里做错了什么?谢谢

0 个答案:

没有答案