C# .Net Gmail Tools

位于code.msdn.microsoft.com的一个小型Library
你可以很简单的使用它来通过gmail发送邮件或者获取Gmail Atom Feed 。
 

   //Send a message with one line of code
   RC.Gmail.GmailMessage.SendFromGmail("username", "password", "toAddress@gmail.com", "subject", "message body");

   //Send a message with one line of code with a MailMessage object
   RC.Gmail.GmailMessage.SendMailMessageFromGmail("username", "password", mailMessageObject);

   //Use the GmailMessage object to create and send your message
   RC.Gmail.GmailMessage gmailMsg = new RC.Gmail.GmailMessage("username", "password");
   gmailMsg.To = "RCcode@gmail.com";
   gmailMsg.From = "fromAddress@gmail.com";
   gmailMsg.Subject = "C# Test Message";
   gmailMsg.Body = "Test body";

   MailAttachment attachment = new MailAttachment(@"c:\testfile.txt");
   gmailMsg.Attachments.Add(attachment);

   gmailMsg.Send();

 

Visit here to download the GMail Tools

// 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;
   }

Visit here to download the GMail Tools

posted on 2008-02-21 14:10 活靶子.Net 阅读(...) 评论(...) 编辑 收藏

导航

公告

统计