当前位置:编程学习 > C#/ASP.NET >>

第四部分,私有方法至结束

答案:        /// <summary>
        /// SMTP回应代码哈希表
        /// </summary>
        private void SMTPCodeAdd()
        {
            ErrCodeHT.Add("500","邮箱地址错误");
            ErrCodeHT.Add("501","参数格式错误");
            ErrCodeHT.Add("502","命令不可实现");
            ErrCodeHT.Add("503","服务器需要SMTP验证");
            ErrCodeHT.Add("504","命令参数不可实现");
            ErrCodeHT.Add("421","服务未就绪,关闭传输信道");
            ErrCodeHT.Add("450","要求的邮件操作未完成,邮箱不可用(例如,邮箱忙)");
            ErrCodeHT.Add("550","要求的邮件操作未完成,邮箱不可用(例如,邮箱未找到,或不可访问)");
            ErrCodeHT.Add("451","放弃要求的操作;处理过程中出错");
            ErrCodeHT.Add("551","用户非本地,请尝试<forward-path>");
            ErrCodeHT.Add("452","系统存储不足,要求的操作未执行");
            ErrCodeHT.Add("552","过量的存储分配,要求的操作未执行");
            ErrCodeHT.Add("553","邮箱名不可用,要求的操作未执行(例如邮箱格式错误)");
            ErrCodeHT.Add("432","需要一个密码转换");
            ErrCodeHT.Add("534","认证机制过于简单");
            ErrCodeHT.Add("538","当前请求的认证机制需要加密");
            ErrCodeHT.Add("454","临时认证失败");
            ErrCodeHT.Add("530","需要认证");

            RightCodeHT.Add("220","服务就绪");
            RightCodeHT.Add("250","要求的邮件操作完成");
            RightCodeHT.Add("251","用户非本地,将转发向<forward-path>");
            RightCodeHT.Add("354","开始邮件输入,以<enter>.<enter>结束");
            RightCodeHT.Add("221","服务关闭传输信道");
            RightCodeHT.Add("334","服务器响应验证Base64字符串");
            RightCodeHT.Add("235","验证成功");
        }


        /// <summary>
        /// 将字符串编码为Base64字符串
        /// </summary>
        /// <param name="estr">要编码的字符串</param>
        private string Base64Encode(string str)
        {
            byte[] barray;
            barray=Encoding.Default.GetBytes(str);
            return Convert.ToBase64String(barray);
        }


        /// <summary>
        /// 将Base64字符串解码为普通字符串
        /// </summary>
        /// <param name="dstr">要解码的字符串</param>
        private string Base64Decode(string str)
        {
            byte[] barray;
            barray=Convert.FromBase64String(str);
            return Encoding.Default.GetString(barray);
        }

       
        /// <summary>
        /// 得到上传附件的文件流
        /// </summary>
        /// <param name="FilePath">附件的绝对路径</param>
        private string GetStream(string FilePath)
        {
            //建立文件流对象
            System.IO.FileStream FileStr=new System.IO.FileStream(FilePath,System.IO.FileMode.Open);
            byte[] by=new byte[System.Convert.ToInt32(FileStr.Length)];
            FileStr.Read(by,0,by.Length);
            FileStr.Close();
            return(System.Convert.ToBase64String(by));
        }


        /// <summary>
        /// 发送SMTP命令
        /// </summary>    
        private bool SendCommand(string str)
        {
            byte[]  WriteBuffer;
            if(str==null||str.Trim()=="")
            {
                return true;
        &n

上一个:例子
下一个:get the mac Address

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,