-1
我正在使用以下代碼從Gmail中讀取電子郵件。但問題是它給未讀的電子郵件。在我來說,我想讀的最後04郵件,不論它已讀或未讀獲取Gmail中的最後郵件
class ReadEmail
{
public void AccessEmail(string userName, string password)
{
try
{
System.Net.WebClient objClient = new System.Net.WebClient();
string response;
string title;
string summary;
//Creating a new xml document
XmlDocument doc = new XmlDocument();
XmlNode nr = default(XmlNode);
//Logging in Gmail server to get data
objClient.Credentials = new System.Net.NetworkCredential(userName, password);
//reading data and converting to string
response = Encoding.UTF8.GetString(
objClient.DownloadData(@"https://mail.google.com/mail/feed/atom"));
response = response.Replace(
@"<feed version=""0.3"" xmlns=""http://purl.org/atom/ns#"">", @"<feed>");
//loading into an XML so we can get information easily
doc.LoadXml(response);
nr = doc.SelectSingleNode(@"/feed/fullcount");
//Reading the title and the summary for every email
foreach (XmlNode node in doc.SelectNodes(@"/feed/entry"))
{
title = node.SelectSingleNode("title").InnerText;
summary = node.SelectSingleNode("summary").InnerText;
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.Write(ex.Message);
}
}
而且完整的電子郵件正文我不能與上面的代碼中看到。