c# - 使用 IMAP 计算 gmail 中的电子邮件数量

标签 c# winforms gmail imap inbox

谁能告诉我如何使用 imap 或其他工具从 gmail 中获取收件箱中未读邮件的数量,并将其显示在 C# WinForms 的标签中?

我试过使用 atom feeds,但从来没有得到它

这是我想要的样子,如果有帮助的话:

Inbox(1)

最佳答案

已解决

这是我在 ImapX 组件中使用的代码:

 ImapX.ImapClient client = new ImapX.ImapClient("imap.gmail.com", 993, true);
        bool result = false;

        result = client.Connection();
        if (result)
            MessageBox.Show("Connection Established");

        result = client.LogIn(textBox1.Text, textBox2.Text);
        if (result)
        {
            MessageBox.Show("Logged in");
            ImapX.FolderCollection folders = client.Folders;
            ImapX.MessageCollection messages = client.Folders["INBOX"].Search("UNSEEN", true); //true - means all message parts will be received from server

            int unread = messages.Count;
            string unseen = unread.ToString();
            button1.Text = unseen;
        }

我只需要将 int 转换为字符串并在按钮中显示字符串(看不见)。感谢 quantumSoup 为我指明了正确的方向

关于c# - 使用 IMAP 计算 gmail 中的电子邮件数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3539692/

相关文章:

c# - 禁用图片框上的图片混合(Windows 窗体 c#)

c# - 是否可以从 XNA 发送电子邮件?

c# - 如何破解一个dBase文件的密码?

c# - 为什么Windows.Forms.Timer的时间间隔随着tick的增加而减少?

c# - 如何为组合框中的每个项目添加图像/图标?

c# - .NET 窗体设计 - 按钮组 "Photoshop Tool Style"

html - 如何清除gmail代理服务器中的缓存图片

c# - .net lambda 表达式和输出参数

python - 附加来自 Google 云端硬盘的文件

swift - 在Swift 3中使用Gmail URL方案时具有HTML正文