您的位置:首页 > 编程语言 > ASP

Asp.Net发送ICQ信息

2015-09-30 14:34 573 查看
想一想我们在网页上直接给朋友发送ICQ信息,那是多么美妙的事情啊。呵呵,在吹牛啊,其实ICQ本来就有在线发送的代码,不过,这些都是AOL给你写好的代码,多没有意思啊。还是自已写的比较好,呵,废话少说,来看代码吧
01
<% @
Page Langua
02
ge="C#" %>
03
<% @ Assembly Name="System.Net" %>
04
<% @ Import Namespace="System.Net"
%>
05
<% @ Import Namespace="System.Net.Sockets"
%>
06
<% @ Import Namespace="System.IO"
%>
07
<% @ Import Namespacewww.0771ybgc.com/xwzxin/5267.html="System.Text"
%>
08
09
<
Script
 
Language
=
"C#"
 
Runat
=
"Server"
>
10
public void Page_Load(Object
src,EventArgs e)
11
{
12
ICQ_Show.Text="如果提交后,在这里显示信息";
13
}
14
15
public void Send_Click(Object
sender,EventArgs e)
16
{
17
string sendmsg;
18
string
commandmsg;
19
//首先取得要发送的信息
20
commandmsg = "from="+ICQ_Name.Twww.0771ybgc.com/xwzxin/5268.htmlext+"&fromemail="+ICQ_Email.Text+"&subject=";
21
commandmsg += ICQ_Subject.Text+"&body="+ICQ_Message.Text+"&to="+ICQ_Number.Text
22
commandmsg += "&Send=Send+Message";
23
//然后就是组装全部的信
24
sendmsg="POST /scripts/WWPMsg.dll
HTTP/1.1\r\n";
25
sendmsg += "Accept: image/gif,
image/x-xbitmap, image/jpeg, image/pjpeg,";
26
sendmsg += " application/vnd.ms-excel,";
27
sendmsg += " application/msword,
application/vnd.ms-powerpoint, */*\r\n";
28
sendmsg += "Accept-Language:www.0771ybgc.com/xwzxin/5269.html》
zh-cn\r\n";
29
sendmsg += "Content-Type:
application/x-www-form-urlencoded\r\n";
30
sendmsg += "Accept-Encoding:
gzip, deflate\r\n";
31
sendmsg += "User-Agent:
www.0771ybgc.com/xwzxin/5278.html>Mozilla/4.0 (compatible; MSIE 5.01; Windows 95)\r\n";
32
sendmsg += "Host: wwp.icq.com\r\n";
33
sendmsg += "Content-Length:
" + commandmsg.Length + "\r\n";
34
sendmsg += "Connection:
Keep-Alive\r\n\r\n";
35
sendmsg += commandmsg +
"\r\n\r\n";
36
37
Byte[] arrMsg=Encoding.Default.GetBytes(sendmsg.ToCharArray());
38
//需要发送的信息处理完毕
39
40
//======下面就是发送这些信息=====
41
//首先是建立一个TCPClient 对象
42
TCPClient tcpc=new TCPClient();
43
if(0==tcpc.Connect("wwp.icq.com",80))
44
{
45
Stream sm = tcpc.GetStream();
46
sm.Write(arrMsg,0,sendmsg.Length);
47
StreamReader sr=new www.0771ybgc.com/xwzxin/5270.html》StreamReader(tcpc.GetStream(),Encoding.Default);
48
string strRev=sr.ReadLine();
49
if(strRev.IndexOf("OK")!=-1)
50
{
51
ICQ_Show.Text="ICQ消息发送成功";
52
}
53
else
54
{
55
ICQ_Show.Text="ICQ消息发送不成功";
56
}
57
58
}
59
else
60
{
61
ICQ_Show.Text="ICQ消息发送不成功,无法联结ICQ服务器";
62
}
63
//关闭TCP联结
64
tcpc.Close();
65
}
66
67
</
script
>
68
<
html
>
69
<
meta
 
http-equiv
=
"Contentwww.0771ybgc.com/xwzxin/5271.html》-Language"
 
content
=
"zh-cn"
>
70
<
head
>
71
<
title
></
title
>
72
</
head
>
73
<
body
>
74
<
form
 
runat
=
"server"
 
>
75
<
table
>
76
<
tr
><
td
 
align
=
center
 
colspan
=
2www.0771ybgc.com/xwzxin/5273.html
>
77
<
asp:Label
 
id
=
"ICQ_Show"
 
runat
=
"server"
 
ForeColor
=
"red"
 
/></
td
></
tr
>
78
<
tr
><
td
>
79
</
tr
>
80
<
tr
><
td
 
align
=
center
 
colspan
=
2
>发送ICQ信息</
td
></
tr
>
81
<
tr
><
td
>您的ICQ号:</
td
><
td
><www.0771ybgc.com/xwzxin/5277.html》
asp:TextBox
 
id
=
"ICQ_Number"
 
runat
=
"server"
 
/></
td
></
tr
>
82
<
tr
><
td
>您的网名:</
td
><
td
><
asp:TextBox
 
id
=
"ICQ_Name"
 
runat
=
"server"
 
/></
td
></
tr
>
83
<
tr
><
td
>您的Email:</
td
><
td
><
asp:TextBox
 
id
=
"ICQ_Email"
 
runat
=
"server"
 
/></
td
></
tr
>
84
<
tr
><
td
>发送主题:</
td
><
td
><
asp:TextBox
 
id
=
"ICQ_Subject"
 
runat
=
"server"
 
/></
td
></
tr
>
85
<
tr
><
td
>发送内容:</
td
><
td
><
asp:TextBox
 
id
=
"ICQ_Message"
 
runat
=
"server"
 
/></
td
></
tr
>
86
<
tr
><
td
><
asp:Button
 
OnClick
=
"Send_Click"
 
Text
=
"发送ICQ信息"
 
RunAt
=
"server"
 
/></
td
></
tr
>
87
</
table
>
88
</
form
>
89
</
body
>
90
</
html
>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: