我收到消息时出错(gmail)

时间:2017-02-01 19:23:20

标签: c#

我在这一行中遇到了问题xdoc.LoadXml(response)
我希望在C#中使用此代码获取我的消息:

WebClient objclient = new WebClient();    
string response = null;    
XmlDocument xdoc = new XmlDocument();
try
{
    objclient.Credentials = new NetworkCredential(log.Trim(), pass.Trim());
    response = Encoding.UTF8.GetString(objclient.DownloadData("http://mail.google.com/mail/mail/feed/atom"));
    response = response.Replace("<feed version=\"0.3\" xmlns=\"http://purl.org/atom/ns#\">", "<feed>");
    xdoc.LoadXml(response); //Load xml file
    if(mailcount > 0)
    {
        emailfrom = new string[mailcount-1];
        email_messages = new string[mailcount-1];
        foreach(XmlNode node1 in xdoc.SelectNodes("feed/entry"))
        {
             ls.Items.Add(node1.SelectSingleNode("title").InnerText);//add to the lisbox 
        }
    }
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message); //msg error
}

0 个答案:

没有答案