日期:2012-01-27  浏览次数:20639 次

        /// <summary>
        /// 接收SMTP服务器回应
        /// </summary>
        private string RecvResponse()
        {
            int StreamSize;
            string ReturnValue = "";
            byte[]  ReadBuffer = new byte[1024] ;
            try
            {
                StreamSize=ns.Read(ReadBuffer,0,ReadBuffer.Length);
            }
            catch
            {
                errmsg="网络连接错误";
                return "false";
            }

            if (StreamSize==0)
            {
                return ReturnValue ;
            }
            else
            {
                ReturnValue = Encoding.Default.GetString(ReadBuffer).Substring(0,StreamSize);
                logs+=ReturnValue;
                return  ReturnValue;
            }
        }


        /// <summary>
        /// 与服务器交互,发送一条命令并接收回应。
        /// </summary>
        /// <param name="Command">一个要发送的命令</param>
        /// <param name="errstr">如果错误,要反馈的信息</param>
        private bool Dialog(string Command,string errstr)
        {
            if(Command==null||Command.Trim()=="")
            {
                return true;
            }
            if(SendCommand(Command))
            {
                string RR=RecvResponse();