日期:2014-05-18 浏览次数:20949 次
string postData = "t=qf_booked_feedback&id=3ef0963350a0570a66a32f2d3dbffc75c190b23cc7690702&to=999999999@qq.com";
//验证码
string verifycode_cn = txtVal.Text.Trim();
//如果输入了验证码
postData += verifycode_cn.Length > 0 ? "&verifycode_cn=" + verifycode_cn : "";
ASCIIEncoding encoding=new ASCIIEncoding();
byte[] data = encoding.GetBytes(postData);
// Prepare web request...
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://list.qq.com/cgi-bin/qf_compose_send");
///测试代码
//CookieContainer mc = new CookieContainer();
//myRequest.CookieContainer = mc;
///测试结束
myRequest.Method = "POST";
myRequest.ContentType="application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream=myRequest.GetRequestStream();
// Send the data.
newStream.Write(data,0,data.Length);
newStream.Close();
// Get response
HttpWebResponse myResponse=(HttpWebResponse)myRequest.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("utf-8"));
string content = reader.ReadToEnd();
reader.Close();
//测试用代码,查看结果
this.richTextBox1.AppendText(content);
this.webBrowser1.DocumentText = content;