Asp.net| program Here I give you a very practical example, is to send ICQ information online. Think about how wonderful it is for us to send ICQ messages directly to our friends on the Web page. Oh, in the boast Ah, in fact, ICQ has been sent online code, but these are AOL to write you a good code, much does not mean AH. Or the self has written better, oh, less nonsense, we look at the code bar.
<script language= "C #" runat= "Server"
public void Page_Load (Object Src,eventargs E)
{
Icq_show.text= "If submitted, show information here";
}
public void Send_click (Object Sender,eventargs e)
{
String sendmsg;
String commandmsg;
Get the information you want to send first
commandmsg = "from=" +icq_name.text+ "&fromemail=" +icq_email.text+ "&subject=";
Commandmsg + + icq_subject.text+ "&body=" +icq_message.text+ "&to=" +icq_number.text
Commandmsg + = "&send=send+message";
And then assemble all the information.
sendmsg= "Post/scripts/wwpmsg.dll http/1.1\r\n";
Sendmsg + = "accept:image/gif, Image/x-xbitmap, Image/jpeg, Image/pjpeg,";
sendmsg + + application/vnd.ms-office/9.shtml ' target= ' _blank ' class= ' article ' >excel ';
Sendmsg + = "Application/msword, Application/vnd.ms-powerpoint, */*\r\n";
Sendmsg + = "accept-language:zh-cn\r\n";
Sendmsg + = "content-type:application/x-www-form-urlencoded\r\n";
Sendmsg + = "accept-encoding:gzip, deflate\r\n";
Sendmsg + = "user-agent:mozilla/4.0 (compatible; MSIE 5.01; Windows) \ r \ n ";
Sendmsg + = "host:wwp.icq.com\r\n";
Sendmsg + = "Content-length:" + commandmsg. Length + "\ r \ n";
Sendmsg + = "connection:keep-alive\r\n\r\n";
Sendmsg + + commandmsg + "\r\n\r\n";
Byte[] Arrmsg=encoding.default.getbytes (sendmsg. ToCharArray ());
The information that needs to be sent is processed
The following is to send this information =====
The first is to create a TcpClient object
TcpClient tcpc=new tcpclient ();
if (0==TCPC. Connect ("wwp.icq.com", 80))
{
Stream sm = tcpc. GetStream ();
Sm. Write (arrmsg,0,sendmsg. Length);
StreamReader sr=new StreamReader (TCPC. GetStream (), encoding.default);
String STRREV=SR. ReadLine ();
if (Strrev.indexof ("OK")!=-1)
{
icq_show.text= "ICQ message sent successfully";
}
Else
{
icq_show.text= "ICQ message sent unsuccessfully";
}
}
Else
{
icq_show.text= "ICQ Message delivery is not successful, can not connect the ICQ server";
}
Turn off TCP connections
Tcpc. Close ();
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.