Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# OpenPop-Gmail-GetMessageCount()返回0(零)_C#_Asp.net_Openpop - Fatal编程技术网

C# OpenPop-Gmail-GetMessageCount()返回0(零)

C# OpenPop-Gmail-GetMessageCount()返回0(零),c#,asp.net,openpop,C#,Asp.net,Openpop,当使用OpenPop连接到Gmail时,我只能检索一次电子邮件,即使我不删除它。使用GetMessageCount()我始终收到0封电子邮件。我怎样才能得到那里所有的电子邮件 只有在阅读并处理它们之后,我才能发出删除命令。我使用以下代码获取电子邮件: using (var client = new Pop3Client()) { // Connect to the server client.Connect(serverData.Hostname, serverData.Port

当使用OpenPop连接到Gmail时,我只能检索一次电子邮件,即使我不删除它。使用GetMessageCount()我始终收到0封电子邮件。我怎样才能得到那里所有的电子邮件

只有在阅读并处理它们之后,我才能发出删除命令。我使用以下代码获取电子邮件:

using (var client = new Pop3Client())
{
    // Connect to the server
    client.Connect(serverData.Hostname, serverData.Port, serverData.UseSsl);

    // Authenticate ourselves towards the server
    client.Authenticate(serverData.Username, serverData.Password, AuthenticationMethod.UsernameAndPassword);

    var emailAmount = client.GetMessageSizes().Count;

    // Fetch all the current uids seen
    var msgCount = client.GetMessageCount();

   .....
}

仅获取未读邮件是POP3的工作原理。如果您想查看和管理旧邮件,应该改用IMAP。

Gmail很特别。看看是什么解释了这种非标准行为


你感兴趣的是,Gmail只会在一次POP3会话中显示一条消息,除非你做了一些特殊的事情,比如在你的用户名前加上“最近的:”字样。

我的应用程序是否可以在每次请求时都有新的会话?如果是,如何进行?我不知道Gmail的技术部分是如何跟踪会话或应用程序ID以知道他们是否应答,但一直“伪造”一个新ID会很酷。这里的“会话”只是一个连接。新连接意味着新会话。这是获得新会话的唯一方法。gmail的问题在于,它们只在一次会话中显示新电子邮件。以后的所有会话都不会看到它,除非您像在帖子中那样做。例如,使用您的用户名连接:“最近:”。有关详细信息,请参阅帖子。