用ASP.Net写一个发送ICQ信息的程序代码
2008-02-23 09:45:36来源:互联网 阅读 ()
<% @ 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="如果提交后,在这里显示信息";
}
public void Send_Click(Object sender,EventArgs e)
{
string sendmsg;
string commandmsg;
//首先取得要发送的信息
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";
//然后就是组装全部的信息
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 95)\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());
//需要发送的信息处理完毕
//======下面就是发送这些信息=====
//首先是建立一个TCPClient 对象
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消息发送成功";
}
else
{
ICQ_Show.Text="ICQ消息发送不成功";
}
}
else
{
ICQ_Show.Text="ICQ消息发送不成功,无法联结ICQ服务器";
}
//关闭TCP联结
tcpc.Close();
}
</script>
<html>
<meta http-equiv="Content-Language" content="zh-cn">
<head>
<title></title>
</head>
<body>
<form runat="server" >
<table>
<tr><td align=center colspan=2>
<asp:Label id="ICQ_Show" runat="server" ForeColor="red" /></td></tr>
<tr><td>
</tr>
<tr><td align=center colspan=2>发送ICQ信息</td></tr>
<tr><td>您的ICQ号:</td><td><asp:TextBox id="ICQ_Number" runat="server" /></td></tr>
<tr><td>您的网名:</td><td><asp:TextBox id="ICQ_Name" runat="server" /></td></tr>
<tr><td>您的Email:</td><td><asp:TextBox id="ICQ_Email" runat="server" /></td></tr>
<tr><td>发送主题:</td><td><asp:TextBox id="ICQ_Subject" runat="server" /></td></tr>
<tr><td>发送内容:</td><td><asp:TextBox id="ICQ_Message" runat="server" /></td></tr>
<tr><td><asp:Button OnClick="Send_Click" Text="发送ICQ信息" RunAt="server" /></td></tr>
</table>
</form>
</body>
</html>
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:正则表达式使用详解
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash