C# .Net Gmail Tools

來源:互聯網
上載者:User

位於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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.