简体   繁体   English

我可以使用pop3client仅下载最新消息,例如仅下载5条最新消息吗?

[英]Can i use pop3client to download only the newestm essages for example only the 5 newest messages?

Now it's downloading all the messages and i have a lot of them on the server of my internet account. 现在它正在下载所有消息,而我的Internet帐户服务器上有很多消息。 Then after i'm downloading all the messages it will download only the newest messages. 然后,在我下载所有消息之后,它将仅下载最新消息。 But i wonder if i wanted on the first time instead of downloading all the messages to download only the newest 5 messages only ? 但是我想知道我是否想第一次而不是下载所有消息仅下载最新的5条消息吗? Or the newest 100 messages only ? 还是仅最新的100条消息? And not all the messages on the server. 并非服务器上的所有消息。

using (var client = new Pop3Client())
                {
                    client.Connect(textServer.Text, Convert.ToInt32(textPort.Text), ssl);
                    client.AuthenticationMechanisms.Remove("XOAUTH2");
                    client.Authenticate(textUser.Text, textPassword.Text);

                    var uids = client.GetMessageUids();

                    for (int i = 0; i < client.Count; i++)
                    {
                        if (backgroundWorker1.CancellationPending)
                        {
                            e.Cancel = true;
                            return;
                        }
                        if (!downloaded.Contains(uids[i]))
                        {
                            allMessages.Add(client.GetMessage(i));
                            newmsg = client.GetMessage(i);
                            downloaded.Add(uids[i]);
                            SaveFullMessage(client.GetMessage(i), i);
                            w = new StreamWriter(emailsIDSFile, true);
                            w.WriteLine(uids[i]);
                            w.Close();
                        }

                        int nProgress = (client.Count - i + 1) * 100 / client.Count;
                        backgroundWorker1.ReportProgress(nProgress,newmsg);//, client.Count.ToString() + "/" + i);
                        newmsg = null;
                    }

                    client.Disconnect(true);
                }

I'm getting a List of all the messages Uids: 我正在获取所有消息Uid的列表:

var uids = client.GetMessageUids();

And i wonder if i could somehow to do something like in logical: Download only the newest 5 Uids messages or the newest 100 Uids messages. 而且我想知道我是否可以通过某种方式做逻辑上的事情:仅下载最新的5个Uid消息或最新的100个Uid消息。 I wonder how and if i can select from the Uids List only the newest 5 or 100 messages to be downloaded. 我想知道如何以及是否可以从Uid列表中选择要下载的最新5或100条消息。

I don't need and don't care for now about all the messages on the server i want to check only for the N newest messages for example 5 or 100 newest messages. 我不需要也不关心服务器上的所有消息,我只想检查N条最新消息,例如5条或100条最新消息。

Instead of calling GetMessageUids, call GetMessageUid multiple times with an increasing message number each time. 而不是调用GetMessageUids,而是多次调用GetMessageUid,每次消息数量都在增加。

See [ http://hpop.sourceforge.net/documentation/OpenPop~OpenPop.Pop3.Pop3Client.GetMessageUid.html] 请参阅[ http://hpop.sourceforge.net/documentation/OpenPop~OpenPop.Pop3.Pop3Client.GetMessageUid.html]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OpenPop.NET:Pop3Client:如何仅获取新电子邮件 - OpenPop.NET : Pop3Client : How to get only the new emails 从pop3client读取邮件时出错 - Error while reading mail from pop3client Pop3Client错误:“不支持7位编码名称” - Pop3Client error: “7bit is not supported encoding name” MailKit:从 Pop3Client class 调用 Authenticate 方法时抛出 Authentication Failed - MailKit: throws Authentication Failed while calling Authenticate method from the Pop3Client class 如何只下载部分页面? - How can I download only part of a page? 如何在服务器广播中使用 signalr 仅对单个客户端,而不是所有客户端? - How can I use signalr in server broadcast to a single client only, not all clients? 如何只查询最新版本? - how to only query newest version? 如何仅使用 asp.net C# 在具有无限记录(例如地址)和此客户端的唯一 ID 的数据库表中插入一个人? - How can I Insert a person in a database table with unlimited records ( addresses for example ) and a unique ID for this client only using asp.net C#? 我可以将整个SPSite或SPWeb下载到硬盘吗(ATM我只能下载1个文件夹) - can I download entire SPSite or SPWeb to harddisk (ATM i can only download 1 folder) 如何仅在客户端应用程序中使用SynchronizationContext - How do I use a SynchronizationContext only in client apps
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM