Read Gmail Inbox

邮差的信 提交于 2019-11-27 02:58:19

问题


I want to read my Gmail Inbox by using Google.GData.Client.dll. How do I accomplish this? I would like a sample program.


回答1:


I found 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; 
   }

also you should look

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

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




回答2:


Use aenetmail's IMAP client: github. I think it's a better alternative than GMailAtomFeed because you can retrieve the entire body of the emails and it has many many more options.

Here's an example:

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
}


来源:https://stackoverflow.com/questions/4461946/read-gmail-inbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!