我需要从许多邮件项目中检索和复制附件。问题是每个邮件项目的集合都是空的,即使属性 HasAttachment 为真。
我是否需要在检索邮件项目后以某种方式加载每个邮件项目的附件集合?
以下代码抛出异常“索引超出范围。”:
FindItemsResults<Item> findResults = service.FindItems(
WellKnownFolderName.Inbox,
new ItemView(1));
foreach (Item item in findResults.Items)
{
if (item.HasAttachments && item.Attachments[0] is FileAttachment)
{
//Do stuff
}
}
Run Code Online (Sandbox Code Playgroud) 更新1:发布/获取标题的屏幕截图:http://imageshack.us/photo/my-images/826/getpost.png
我正在寻求Web请求的帮助.请求的目的是登录站点并检索Set-Cookie标头.我很感激任何帮助!
我对网络请求有点新意,所以请跟我一起玩.我正在尝试使用以下代码登录网站并检索cookie值.但是,Set-Cookie标头始终为null:
static void Main(string[] args)
{
string formUrl = "https://account.guildwars2.com/login";
string formParams = string.Format("email={0}&password={1}", "xxx", "xxx");
string cookieHeader;
var req = (HttpWebRequest)WebRequest.Create(formUrl);
req.Referer = "https://account.guildwars2.com/login";
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
req.KeepAlive = true;
byte[] bytes = Encoding.ASCII.GetBytes(formParams);
req.ContentLength = bytes.Length;
using (Stream os = req.GetRequestStream())
{
os.Write(bytes, 0, bytes.Length);
}
WebResponse resp = req.GetResponse();
cookieHeader = resp.Headers["Set-Cookie"];
}
Run Code Online (Sandbox Code Playgroud)
我不确定这是否与重定向有关,因为在C#应用程序中,response-uri是"https://account.guildwars2.com/login?redirect_uri=/download"
响应标头Chrome