Asp. NET send ICQ message DIY

Source: Internet
Author: User
Tags getstream sendmsg net send
asp.net ASP. NET send ICQ information diy<br>
<br>
<br>
<br>
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 is it better to write, oh, nonsense less say, everyone to see Code <br>
<br>
<% @ Page language= "C #"%><br>
<% @ Assembly name= "System.Net"%><br>
<% @ Import namespace= "System.Net"%><br>
<% @ Import namespace= "System.Net.Sockets"%><br>
<% @ Import namespace= "System.IO"%><br>
<% @ Import namespace= "System.Text"%><br>
<br>
<script language= "C #" runat= "Server" ><br>
public void Page_Load (Object Src,eventargs e) <br>
{<br>
Icq_show.text= "If submitted, show information here"; <br>
}<br>
<br>
public void Send_click (Object sender,eventargs e) <br>
{<br>
String sendmsg;<br>
String commandmsg;<br>
file://first get the information to send <br>
commandmsg = "from=" +icq_name.text+ "&fromemail=" +icq_email.text+ "&subject="; <br>
Commandmsg + + icq_subject.text+ "&body=" +icq_message.text+ "&to=" +icq_number.text <br>
commandmsg = "&send=send+message";<br>
FILE://is then assembled with all the information <br>
sendmsg= "Post/scripts/wwpmsg.dll http/1.1\r\n";<br>
Sendmsg + = "accept:image/gif, Image/x-xbitmap, Image/jpeg, Image/pjpeg,";<br>
sendmsg = "Application/vnd.ms-excel,";<br>
Sendmsg + = "Application/msword, Application/vnd.ms-powerpoint, */*\r\n";<br>
sendmsg = "accept-language:zh-cn\r\n";<br>
sendmsg = "content-type:application/x-www-form-urlencoded\r\n";<br>
sendmsg = "Accept-encoding:gzip, deflate\r\n";<br>
Sendmsg + = "user-agent:mozilla/4.0 (compatible; MSIE 5.01; Windows) \ r \ n ";<br>
sendmsg = "host:wwp.icq.com\r\n";<br>
Sendmsg + = "Content-length:" + commandmsg. Length + "\ r \ n";<br>
sendmsg = "connection:keep-alive\r\n\r\n";<br>
Sendmsg + + commandmsg + "\r\n\r\n";<br>
<br>
Byte[] Arrmsg=encoding.default.getbytes (sendmsg. ToCharArray ());<br>
file://need to send the information processing finished <br>
<br>
file://====== below is the message to send =====<br>
file://first is to create a TcpClient object <br>
TcpClient tcpc=new tcpclient ();<br>
if (0==TCPC. Connect ("wwp.icq.com") <br>
{<br>
Stream sm = tcpc. GetStream ();<br>
Sm. Write (arrmsg,0,sendmsg. Length);<br>
StreamReader sr=new StreamReader (TCPC. GetStream (), Encoding.default);<br>
String STRREV=SR. ReadLine ();<br>
if (Strrev.indexof ("OK")!=-1) <br>
{<br>
icq_show.text= "ICQ message sent successfully";<br>
}<br>
Else<br>
{<br>
icq_show.text= "ICQ message send unsuccessful";<br>
}<br>
<br>
}<br>
Else<br>
{<br>
icq_show.text= "ICQ message delivery is unsuccessful and cannot connect to the ICQ server";<br>
}<br>
file://shut down TCP connections <br>
Tcpc. Close ();<br>
}<br>
<br>
</script> <br>
<meta http-equiv= "Content-language" content= "ZH-CN" ><br>
<title> </title> <br>
<body> <br>
<form runat= "Server" ><br>
<table> <br>
<tr> <td Align=center colspan=2><br>
<asp:label id= "icq_show" runat= "server" forecolor= "Red"/> </td> </tr> <br>
<tr> <td> <br> </tr> <br>
<tr> <td align=center colspan=2> send ICQ messages </td> </tr> <br>
<tr> <td> your ICQ: </td> <td> <asp:textbox id= "Icq_number" runat= "Server"/> </td> </tr> <br>
<tr> <td> Your network name: </td> <td> <asp:textbox id= "icq_name" runat= "Server"/> </td> </tr> <br>
<tr> <td> your Email: </td> <td> <asp:textbox id= "Icq_email" runat= "Server"/> </td> </tr> <br>
<tr> <td> Send a topic: </td> <td> <asp:textbox id= "Icq_subject" runat= "Server"/> </td> </tr> <br>
<tr> <td> Send content: </td> <td> <asp:textbox id= "icq_message" runat= "Server"/> </td> </tr> <br>
<tr> <td> <asp:button onclick= "Send_click" text= "send ICQ message" runat= "Server"/> </td> </tr> <br>
</table> <br>
</form> <br>
<br>
</body> <br>
<br>
It's starting to look like this:<br>
<br>
If submitted, show information here <br>
<br>
Send ICQ information <br>
Your ICQ number: <br>
Your Network Name: <br>
Your email: <br>
Send a topic: <br>
Send content: <br>
<br>
Press the "Send ICQ message" key after the display is:<br>
<br>
ICQ message sent successfully <br>
<br>
<br>
Send ICQ information <br>
Your ICQ number: <br>
Your Network Name: <br>
Your email: <br>
Send a topic: <br>
Send content: <br>
<br>
I believe you can read the above procedures, I have added a note, should be no problem. Oh. In fact, this program is only in the same way as AOL online code, but wrote a program to simulate the post method. But that's enough, and when we write a program, it doesn't have to be annoying for that post. <br>
<br>
With ICQ information, certainly many friends will ask to Oicq, after all, in the domestic OICQ is the eldest. But unfortunately, Tencent did not provide us with the interface, I wrote to ask, they told me did not provide, in fact, I also got one, is through the WAP way to get. But this is not very good, can only be sent to the company of the form of notice, very bad play, but also must be online to receive users, too no meaning. Originally also want to write directly through UDP, but really do not know, this data package to fill some things to verify, so there is no way, if any friend know, please write to me, I also in the waiting AH. <br>
<br>
About this send ICQ Information example demonstration, I put it on the http://aspx1.brinkster.com/feidao/code/Qicq.aspx, everybody is interested to see, hehe. <br>
<br>


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.