2010-12-16 131 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 
}