2011-08-22 67 views
0

我有一個關於gmail gdata api和他在c#上的實現的問題。 我想從用戶Gmail帳戶(與他以前通過oauth授權)的電子郵件,但我不知道該怎麼做。 我有這樣的代碼:從c#獲取gmail收件箱與GData

AccessToken = GetGoogleToken(); 
      GOAuthRequestFactory requestFactory = new GOAuthRequestFactory("cp", TokenManager.ConsumerKey); //ConsumerKey actually is the name of web application 
      requestFactory.ConsumerKey = TokenManager.ConsumerKey; 
      requestFactory.ConsumerSecret = TokenManager.ConsumerSecret; 
      requestFactory.Token = AccessToken; 
      requestFactory.TokenSecret = GetGoogleTokenSecret(); 
      requestFactory.UseSSL = true; 
      Service service = new Service(requestFactory.ApplicationName); 
      service.RequestFactory = requestFactory; 
      FeedQuery query = new FeedQuery("https://mail.google.com/mail/feed/atom/work/"); 

      AtomFeed mails = service.Query(query); 
      string feeds = ""; 
      foreach (AtomEntry item in mails.Entries) { 
       feeds += "\n" + item.Title.Text; 
      } 

這不工作對我來說..條目總是空的。 我缺少什麼? 我希望你能幫助我! 謝謝!

回答

1

我一直在閱讀文檔,因爲我也需要這個功能。看起來,使用Atom提要只會返回新的電子郵件。我認爲這意味着未讀的電子郵件。

http://code.google.com/apis/gmail/docs/inbox_feed.html

看起來你可能想看看SMTP和IMAP方法作爲解決方案以獲取列表。

+0

我已閱讀,但我想有一個示例代碼,因爲我不知道如何使用此提要。 –