[英]Reading Emails from Gmail C# - IMAP
我正在尝试阅读来自特定Gmail帐户的电子邮件。 我在这里找到了一些东西(Stackoverflow),但是我无法管理阅读电子邮件。
这就是我正在使用的:
public static void logingmail()
{
// Connect to the IMAP server. The 'true' parameter specifies to use SSL
// which is important (for Gmail at least)
ImapClient ic = new ImapClient("imap.gmail.com", "Any@gmail.com", "4521945219",AuthMethods.Login, 993, true);
// Select a mailbox. Case-insensitive
ic.SelectMailbox("Inbox");
string countmessages = ic.GetMessageCount().ToString();
// Get the first *11* messages. 0 is the first message;
// and it also includes the 10th message, which is really the eleventh ;)
// MailMessage represents, well, a message in your mailbox
MailMessage[] mm = ic.GetMessages(0, 10);
foreach (MailMessage m in mm)
{
var subject = m.Subject.ToString();
}
// Probably wiser to use a using statement
ic.Dispose();
}
当我第一次创建新的ImapCliient类时,可能会遇到我遇到的问题。 由于某种原因,它正在打开浏览路径以选择文件(?)。 我很乐意提供帮助。 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.