【问题标题】:Read Gmail Inbox阅读 Gmail 收件箱
【发布时间】:2010-12-16 14:45:50
【问题描述】:

我想使用 Google.GData.Client.dll 阅读我的 Gmail 收件箱。我该如何做到这一点?我想要一个示例程序。

【问题讨论】:

标签: c# google-data-api


【解决方案1】:

我找到GMailAtomFeed

   // Create the object and get the feed 
   RC.Gmail.GmailAtomFeed gmailFeed = new RC.Gmail.GmailAtomFeed("username", "password"); 
   gmailFeed.GetFeed(); 

   // Access the feeds XmlDocument 
   XmlDocument myXml = gmailFeed.FeedXml 

   // Access the raw feed as a string 
   string feedString = gmailFeed.RawFeed 

   // Access the feed through the object 
   string feedTitle = gmailFeed.Title; 
   string feedTagline = gmailFeed.Message; 
   DateTime feedModified = gmailFeed.Modified; 

   //Get the entries 
   for(int i = 0; i < gmailFeed.FeedEntries.Count; i++) { 
      entryAuthorName = gmailFeed.FeedEntries[i].FromName; 
      entryAuthorEmail = gmailFeed.FeedEntries[i].FromEmail; 
      entryTitle = gmailFeed.FeedEntries[i].Subject; 
      entrySummary = gmailFeed.FeedEntries[i].Summary; 
      entryIssuedDate = gmailFeed.FeedEntries[i].Received; 
      entryId = gmailFeed.FeedEntries[i].Id; 
   }

你也应该看看

http://code.msdn.microsoft.com/CSharpGmail

http://weblogs.asp.net/satalajmore/archive/2007/12/19/asp-net-read-email.aspx

【讨论】:

  • 注意:此提要仅适用于 Google Apps 域中的 Gmail 帐户(似乎没有说明付费与未付费的任何内容)。 developers.google.com/google-apps/gmail/gmail_inbox_feed
  • 这有效,但仅用于检索电子邮件主题而不是正文。此外,您只能获得每个文件夹的前 20 封电子邮件。
【解决方案2】:

使用 aenetmail 的 IMAP 客户端:github。我认为它是比 GMailAtomFeed 更好的选择,因为您可以检索整个电子邮件正文,并且它有更多选择。

这是一个例子:

using (var ic = new AE.Net.Mail.ImapClient("imap.gmail.com", "email", "pass", AE.Net.Mail.AuthMethods.Login, 993, true))
{
    ic.SelectMailbox("INBOX");
    MailMessage[] mm = ic.GetMessages(0, 10);
    // at this point you can download the messages
}

【讨论】:

    猜你喜欢
    • 2014-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-19
    • 1970-01-01
    • 2011-11-15
    • 2014-05-20
    相关资源
    最近更新 更多