我想使用Google.GData.Client.dll
阅读我的Gmail收件箱。我该如何做到这一点?我想要一个示例程序。
答案 0 :(得分: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 :(得分: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
}