//得到登录页面的代码
Url := 'http://login.live.com/login.srf?id=2';
Memo1.Text := IdHTTP1.Get( Url );
//我截获浏览器提交的网址请求发现有一个MUID的Cookie,发现通过下面这些代码可以得到,前面两个没发现在哪一步设置的,所以直接添加进去了。
idcookie.AddCookie( 's_cc=true; domain=.msn.com; expires=Fri, 01-Jan-2021 00:00:00 GMT; path=/; ', '.msn.com' );
idcookie.AddCookie( 's_sq=%5B%5BB%5D%5D; domain=.msn.com; expires=Fri, 01-Jan-2021 00:00:00 GMT; path=/;', '.msn.com' );
IdHttp1.Request.Referer := 'http://hm.msn.com/c/hotmail/N/2052/footer.html?cbpage=login&lc=2052&x=5.0.7495.0';
try
  IdHttp1.HandleRedirects := true;
  Url := 'http://c.msn.com/c.gif?na=1137&nc=9523&ps=8312&di=915&pi=44281&xtpid=1005&TP=http%3a%2f%2fcb2.msn.com%2ffooter.armx';
  IdHttp1.Get( Url );  //此处好像报错:connection closed gracefully
except
end;
/// 模拟浏览器提交用户名和密码
Params := TIdMultiPartFormDataStream.Create;
Params.AddFormField('PPSX', getInputElementValueByName(Memo1.Text,'PPSX')); //自己写的小函数从源码中取字段值
Params.AddFormField('PPFT', getInputElementValueByName(Memo1.Text,'PPFT'));
Params.AddFormField('PwdPad', '');
Params.AddFormField('LoginOptions', '3');
Params.AddFormField('login', '[email protected]');
Params.AddFormField('passwd', '**********'); //程序中这地方是/ppsecure/post.srf?id=2&bk=1188804422'; //每次后面这个号都不一样,但用不变的固定值,服务器返回的html代码好像都是成功的!
IdHttp1.Post(Url,Params,ret);
Memo2.Text := ret.DataString;
Params.Free;
ret.Free;//根据返回的成功代码,登录邮箱
i := Pos('replace("http',Memo2.Text);    //从代码是取登录邮箱的 URL
Url := Copy(Memo2.Text, i+9, Length(Memo2.Text)-i-8);
i := Pos('");',Url);
Url := Copy(Url,1,i-1);
try
  //IdHttp1.HandleRedirects := true;
  IdHttp1.Request.ContentType := '';
  Idhttp1.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash,  */*';
  Idhttp1.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*';
  IdHttp1.Request.Connection := 'Keep-Alive';
  Idhttp1.Request.AcceptEncoding := 'gzip, deflate';  Memo4.Text := IdHttp1.Get(Url);  //这个好像也牵扯 redirect, 也会报错,如果把HandleRedirects 设置为false 就能从 response.location 得到要跳转的网址,于是可以在 except 中访问那个网址except
  Url := IdHttp1.Response.Location;
  Memo4.Text := IdHttp1.Get( Url ); //在此处总是出错,不能正确登录,但是将这个URL输入浏览器的网址栏就能正确地进入hotmail邮箱
end;请高人指点我哪儿出错了,帮我找到一个登录hotmail邮箱的方法,将不胜感激!