Asp. NET send ICQ information DIY (1)

Source: Internet
Author: User
Tags getstream connect sendmsg net send
Here I provide you with 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, nonsense less say, we look at the code

<% @ Page language= "C #"%>
<% @ Assembly name= "System.Net"%>
<% @ Import namespace= "System.Net"%>
<% @ Import namespace= "System.Net.Sockets"%>
<% @ Import namespace= "System.IO"%>
<% @ Import namespace= "System.Text"%>

<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;
file://first get the information you want to send
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";
file://and then it's all about assembling 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-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 ());
file://need to send the information processing finished

file://====== below is the message to send =====
file://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";
}
file://Shut down TCP connections
Tcpc. Close ();
}

</script>
<meta http-equiv= "Content-language" content= "ZH-CN"
<title> </title>
<body>
<form runat= "Server" >
<table>
<tr> <td Align=center colspan=2>
<asp:label id= "icq_show" runat= "server" forecolor= "Red"/> </td> </tr>
<tr> <td> <br> </tr>
<tr> <td align=center colspan=2> send ICQ messages </td> </tr>
<tr> <td> your ICQ: </td> <td> <asp:textbox id= "Icq_number" runat= "Server"/> </td> </tr>
<tr> <td> Your network name: </td> <td> <asp:textbox id= "icq_name" runat= "Server"/> </td> </tr>
<tr> <td> your Email: </td> <td> <asp:textbox id= "Icq_email" runat= "Server"/> </td> </tr>
<tr> <td> Send a topic: </td> <td> <asp:textbox id= "Icq_subject" runat= "Server"/> </td> </tr>
<tr> <td> Send content: </td> <td> <asp:textbox id= "icq_message" runat= "Server"/> </td> </tr>
<tr> <td> <asp:button text= "send ICQ message" runat= "Server"/> </td> </tr>
</table>
</form>

</body>


Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.