Using System;
Using System.Web;
Using System.Net;
Using System.IO;
Using System.Text;
Namespace SendMessage
{
public bool Sendmsg (Msginfo msg)
{
Create request
Try
{
WebRequest req = webrequest.create ("Http://your_post_url");
Set the request parameter
Req. method = "POST";
Req. ContentType = "application/x-www-form-urlencoded";
QueryString '? Msg=xxx&type=0 '
String strquery = "msg=";
Strquery + + httputility.urlencode (msg);
Strquery + = "&type=0";
string datasend = strquery;
Req. ContentLength = Datasend.length;
byte [] buff = Encoding.UTF8.GetBytes (datasend);
Stream Reqstream = req. GetRequestStream ();
Reqstream.write (buff, 0, buff. Length);
Reqstream.close ();
WebResponse rep = req. GetResponse ();
Stream Repstream = Rep. GetResponseStream ();
Encoding enc = encoding.getencoding ("Utf-8");
StreamReader sr = new StreamReader (Repstream, ENC);
char[] Read = new char[256];
Sr. Read (read, 0, 256);
return true;
}
catch (NotSupportedException NS)
{
return false;
}
}
}