谁能告诉我如何使用 imap 或其他工具从 gmail 中获取收件箱中未读邮件的数量,并将其显示在 C# WinForms 的标签中?
我试过使用 atom feeds,但从来没有得到它
这是我想要的样子,如果有帮助的话:
最佳答案
已解决
这是我在 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/