21 Feb 2008

C# .Net Gmail Tools

Share

位于code.msdn.microsoft.com的一个小型Library

你可以很简单的使用它来通过gmail发送邮件或者获取Gmail Atom Feed 。

 

   //Send a message with one line of code

   RC.Gmail.GmailMessage.SendFromGmail(“username”, “password”, “[email protected]”, “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 = “[email protected]”;

   gmailMsg.From = “[email protected]”;

   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

comments powered by Disqus