我有一个项目,它将向 Gmail 帐户发送一封包含某些数据的电子邮件。我认为阅读 Atom feed 可能比通过 POP 连接更容易。
根据谷歌我应该使用的网址是:
https://gmail.google.com/gmail/feed/atom
问题是:如何验证我想查看的电子邮件帐户?如果我在 Firefox 中执行此操作,它会使用 cookie。
我还不确定如何准确地“下载”此请求应返回的 XML 文件(我认为正确的术语是流)。
Edit 1:
我正在使用.Net 3.5。
这是我在 Vb.net 中使用的:
objClient.Credentials = New System.Net.NetworkCredential(username, password)
objClient 的类型为 System.Net.WebClient。
然后,您可以使用如下方式从提要中获取电子邮件:
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# 中应该没有太大不同。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)