c# - OpenPop.Net 没有收到来自 Gmail 的所有电子邮件

标签 c# email gmail-api openpop

我有这个代码:

public List<Attachment> GetAttachments() {
    string hostname = "pop.gmail.com";
    int port = 995;
    bool useSSL = true;
    string attachmentType = "application/pdf";

    string email = "myemail@gmail.com";
    string emailFrom = "someone@gmail.com";
    string password = TxtBoxPassword.Text;

    if (!string.IsNullOrWhiteSpace(password))
    {
        Pop3Client client = new Pop3Client();
        client.Connect(hostname, port, useSSL);
        client.Authenticate(email, password, AuthenticationMethod.UsernameAndPassword);

        List<Attachment> listAttachments = new List<Attachment>();

        int count = client.GetMessageCount();
        for (int i = count; i >= 1; i--)
        {
            Message message = client.GetMessage(i);
            if (message.Headers.From.MailAddress.Address == emailFrom)
            {
                List<MessagePart> attachments = message.FindAllAttachments();
                foreach (MessagePart attachment in attachments)
                {
                    if (attachment.ContentType.MediaType == attachmentType)
                        listAttachments.Add(new Attachment(attachment));
                }
            }
        }
    }
}

阅读电子邮件帐户中的所有电子邮件。

它访问电子邮件帐户并从已发送/收件箱文件夹中获取 265 封电子邮件。

目前我的帐户中有超过一千封电子邮件,所以我希望在电子邮件数量上看到这个数字。

阻止我接收所有电子邮件的代码/Gmail 帐户设置中缺少什么?

谢谢

最佳答案

嗯,Gmail 在涉及其 POP3 功能时有一些怪癖。在 What non-standard behaviour features does Gmail exhibit, when it is programmatically used as a POP3 server? 上查看我的回答.我不认为您可以更改任何设置来解决您的问题。

关于c# - OpenPop.Net 没有收到来自 Gmail 的所有电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31308255/

相关文章:

android - MesageID Android Gmail API

c# - jQuery 自动完成文本不通过使用 MVC3 创建 View 保存到数据库

c# - 如何在具有不同where子句的Linq lambda中使用两个条件

c# - 如何将代理与 TcpClient.ConnectAsync() 一起使用?

java - 在 JSP 中使用 Java 类

azure - 使用 powershell、cmd 或 python 自动创建 M365 Outlook 配置文件

php - 如何设置 Debian Linux 默认发送邮件/发送邮件应用程序/脚本?

javascript - 使用 Google javascript API 进行身份验证

python - 有没有办法检查用户和通行证在 python 3 中的 gmail 中是否有效?

c# - TFS API : Retrieve changesets from main branch using VersionControlServer. 查询历史记录