用ASP.Net写一个发送ICQ信息的程序

2016-01-29 13:51 13 1 收藏

用ASP.Net写一个发送ICQ信息的程序,用ASP.Net写一个发送ICQ信息的程序

【 tulaoshi.com - ASP.NET 】

这里我给大家提供一个很实用的例子,就是在线发送ICQ信息。想一想我们在网页上直接给朋友发送ICQ信息,那是多么美妙的事情啊。呵呵,在吹牛啊,其实ICQ本来就有在线发送的代码,不过,这些都是AOL给你写好的代码,多没有意思啊。还是自已写的比较好,呵呵,废话少说,大家来看代码吧 <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="如果提交后,在这里显示信息"; <br
} <br
<br
public void Send_Click(Object sender,EventArgs e) <br
{ <br
string sendmsg; <br
string commandmsg; <br
//首先取得要发送的信息 <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
//然后就是组装全部的信息 <br
sendmsg="POST /scripts/WWPMsg.dll HTTP/1.1rn"; <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, */*rn"; <br
sendmsg += "Accept-Language: zh-cnrn"; <br
sendmsg += "Content-Type: application/x-www-form-urlencodedrn"; <br
sendmsg += "Accept-Encoding: gzip, deflatern"; <br
sendmsg += "User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows 95)rn"; <br
sendmsg += "Host: wwp.icq.comrn"; <br
sendmsg += "Content-Length: " + commandmsg.Length + "rn"; <br
sendmsg += "Connection: Keep-Alivernrn"; <br
sendmsg += commandmsg + "rnrn"; <br
<br
Byte[] arrMsg=Encoding.Default.GetBytes(sendmsg.ToCharArray()); <br
//需要发送的信息处理完毕 <br
<br
//======下面就是发送这些信息===== <br
//首先是建立一个TCPClient 对象 <br
TCPClient tcpc=new TCPClient(); <br
if(0==tcpc.Connect("wwp.icq.com",80)) <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消息发送成功"; <br
} <br
else <br
{ <br
ICQ_Show.Text="ICQ消息发送不成功"; <br
} <br
<br
} <br
else <br
{ <br
ICQ_Show.Text="ICQ消息发送不成功,无法联结ICQ服务器"; <br
} <br
//关闭TCP联结 <br
tcpc.Close(); <br
} <br
<br
</script <br
<html <br
<meta http-equiv="Content-Language" content="zh-cn" <br
<head <br
<title</title <br
</head <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发送ICQ信息</td</tr <br
<tr<td您的ICQ号:</td<td<asp:TextBox id="ICQ_Number" runat="server" /</td</tr <br
<tr<td您的网名:</td<td<asp:TextBox id="ICQ_Name" runat="server" /</td</tr <br

来源:http://www.tulaoshi.com/n/20160129/1491791.html

延伸阅读
标签: Web开发
Abs(number) 取得数值的绝对值。    Asc(String) 取得字符串表达式的第一个字符ASCII 码。    Atn(number) 取得一个角度的反正切值。    CallByName (object, procname, usecalltype,[args()]) 执行一个对象的方法、设定或传回对象的属性。 &nbs...
//主要方法 protected void btnGo_Click (object sender, System.EventArgs e) { //解析url string strServer = this.txtServer.Text ; string strUrl = this.txtFileName.Text ; char [] point = {'.'} ; //定义分割符为"." char[] line = {'/'} ; //定义分割符为"." string [] arrString = strUrl.Split(line) ; //求asp文件全名 string s...
标签: PHP
          来源:Richard Heyes       <?   error_reporting(63);   include('class.html_mime_mail.inc');      /***************************************   ** Example of usage.   ************...
ScreenSaver.cs using System;using System.Windows.Forms; namespace ScreenSaver{ public class DotNETScreenSaver { [STAThread] static void Main(string[] args) { if (args.Length > 0) { if (args[0].ToLower().Trim().Substring(0,2) == "/c") { MessageBox.Show("This Screen Saver has no options you can set."...
标签: PHP
在开始这篇文章时,作者假设读者已能够写出一个用户的登入认证程序. ---------------------------------------------------------- 记数器可完成访问 web 页的总次数,但却不能得知一个时段中访问量的动态记载,下面就来介绍如何写一个各个时段动态显示访问量的方法. 要记载访问量,首先就要在 mysql 内建立一个数据库,姑且给这...

经验教程

401

收藏

21
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部