从C#的Gmail帐户阅读Atom提要 [英] Reading Atom feed of gmail account from C#
问题描述
我有一个项目,将具有一定的数据发送电子邮件到Gmail帐户。我认为,它可能会更容易阅读Atom提要,而不是通过弹出连接
I have a project that will send an email with certain data to a gmail account. I think that it will probably be easier to read the atom feed rather than connect through pop
这是我应该使用根据谷歌是
the url that I should be using according to google is
https://gmail.google.com/gmail/feed/atom
问题/问题是如何验证我想看到(如果我在Firefox做它熄灭饼干
The question/problem is how do I authenticate the email account I want to see ( if I do it in Firefox it goes off the cookies
我也不确定究竟如何下载的xml文件,这个要求应该返回(我认为适当的期限是流)
I'm also uncertain how exactly to "download" the xml file that this request should return ( I believe the proper term is stream)
EDIT1:
我使用.NET 3.5
I am using .net 3.5
推荐答案
这是我在Vb.net使用的:
This is what I used in Vb.net:
objClient.Credentials = New System.Net.NetworkCredential(username, password)
objClient的类型是System.Net.WebClient的。
objClient is of type System.Net.WebClient.
您然后可以使用像这样得到的饲料电子邮件:
You can then get the emails from the feed using something like this:
Dim nodelist As XmlNodeList
Dim node As XmlNode
Dim response As String
Dim xmlDoc As New XmlDocument
'get emails from gmail
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>")
'Get the number of unread emails
xmlDoc.LoadXml(response)
node = xmlDoc.SelectSingleNode("/feed/fullcount")
mailCount = node.InnerText
nodelist = xmlDoc.SelectNodes("/feed/entry")
node = xmlDoc.SelectSingleNode("title")
这不应该是在C#中非常不同的。
This should not be very different in C#.
这篇关于从C#的Gmail帐户阅读Atom提要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!