主要是为了自己使用,大家可以自己去扩充。
全部代码:
using System;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
namespace OSLeagueForumXP.Components
{
/// <summary>
/// TcpClient派生类,用来进行SMTP服务器的连接工作
/// </summary>
public class SMTPClient : TcpClient
{
/// <summary>
/// 进行SMTP服务器的连接
/// </summary>
public SMTPClient()
{
}
/// <summary>
/// 是否以连接
/// </summary>
/// <returns>连接为True,不连接为False</returns>
public bool isConnected()
{
return Active;
}
/// <summary>
/// 向服务器发送命令
/// </summary>
/// <param name="Command">命令</param>
public void SendCommandToServer(string Command)
{
NetworkStream ns = this.GetStream() ;
byte[] WriteBuffer ;
WriteBuffer = new byte[1024] ;
WriteBuffer = Encoding.Default.GetBytes(Command);
ns.Write(WriteBuffer,0,WriteBuffer.Length);
return ;
}
/// <summary>
/// 取得服务器反馈信息
/// </summary>
/// <returns>字符串</returns>
public string GetServerResponse()
{
int StreamSize ;
string ReturnValue = "" ;
byte[] ReadBuffer ;
NetworkStream ns = this.GetStream() ;
ReadBuffer = new byte[1024] ;
StreamSize =