0

我正在设计的程序的一部分需要“阅读”并将电子邮件的主体(如果可能的话从 g-mail 帐户)放入字符串中。

我该怎么办?当谈到 C#-to-web 交互时,我很迷茫。

任何帮助或资源将不胜感激!

澄清一下,我想在收到电子邮件时对其进行处理,而不是一次处理所有电子邮件。

4

2 回答 2

0

From stackoverflow

I found 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; 
   }

also you should look

http://code.msdn.microsoft.com/CSharpGmail

http://weblogs.asp.net/satalajmore/archive/2007/12/19/asp-net-read-email.aspx

As for processing them as they come, you will just have to set up a process to poll for new mail.

于 2013-08-22T16:46:52.930 回答
0

以供参考,

在 nugit 上使用 S22.Imap 包

using (var client = new ImapClient("imap.gmail.com", 993,
         "username", "password", AuthMethod.Login, true))
        {
            var uids = client.Search(SearchCondition.Unseen());
            if (uids.Length >= 1)
            {
                var message = client.GetMessage(uids[0], false, "inbox");
                return new MessageInfo {EnclosedText = message.Body, Sender = message.From.ToString()};
            }
            return new MessageInfo();

        }
于 2013-09-05T16:35:27.327 回答