1

我正在尝试从流行服务器下载看不见的电子邮件。我正在尝试此代码(从 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它也无济于事。
如果我不调试代码让应用程序运行,那么它会继续运行并且永远不会退出循环。
我在这里做错了什么?谢谢

4

0 回答 0