2010-12-16 128 views
4

我想使用Google.GData.Client.dll閱讀我的Gmail收件箱。我該如何做到這一點?我想要一個示例程序。閱讀Gmail收件箱

+5

谷歌是 – 2010-12-16 14:48:12

+0

拿這裏來看看你最好的朋友: https://developers.google.com/gdata/client-cs這是官方文檔。如果你可以將你的問題分解成你想完成的具體的事情,我們可以幫助更多。 – Brad 2010-12-16 14:49:23

回答

5

我發現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

+1

注意:此訂閱源僅適用於Google Apps域上的Gmail帳戶(它似乎沒有提及任何有關付費與未付款的內容)。 https://developers.google.com/google-apps/gmail/gmail_inbox_feed – 2012-12-01 06:48:44

+0

這是有效的,但僅用於檢索電子郵件主題而不是主體。此外,您只能獲得每個文件夾的前20個電子郵件。 – ytoledano 2014-03-30 21:10:54

0

使用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 
}