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

怎么捕获邮件的异常(NO SUCH User) 最后的30分

     public string CDOsendmail_CC(string server, string port, string from, string to, string subject,
            string body, string uid, string pwd, string cc)
        {
            string info = "";
            try
            {

                CDO.Message Msg = new CDO.Message();
                Msg.From = from;
                Msg.To = to;


                #region 加入抄送人
                if (!cc.Trim().Equals(""))
                {
                    Msg.CC = cc.Trim();
                }
                #endregion

                Msg.Subject = subject;
                Msg.HTMLBody = body;



                CDO.IConfiguration Config = Msg.Configuration;
                ADODB.Fields oFields = Config.Fields;
                //cdoSendUsingPort
                oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value = 2;
                oFields["http://schemas.microsoft.com/cdo/configuration/sendusing"].Value = 2;
                oFields["http://schemas.microsoft.com/cdo/configuration/sendusername"].Value = uid;
                oFields["http://schemas.microsoft.com/cdo/configuration/sendpassword"].Value = pwd;
                oFields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"].Value = 1;
                oFields["http://schemas.microsoft.com/cdo/configuration/languagecode"].Value = 0x0804;
                oFields["http://schemas.microsoft.com/cdo/configuration/smtpserver"].Value = server;
                oFields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"].Value = Int32.Parse(port);
                //oFields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"].Value=2025;
                //oFields[CDO.CdoConfiguration.cdoSMTPServerPort].Value=Int32.Parse(port);



                //cdoSMTPServerPort

                oFields.Update();


                Msg.BodyPart.Charset = "gb2312";
                Msg.HTMLBodyPart.Charset = "gb2312";


                Msg.Send();
                Msg = null;
                info = "T";

                oFields.CancelUpdate();
                
                string suceed_msg=to+": 发送成功!";
                writelog(suceed_msg);
            }
            catch (Exception err)
            {
                info = err.ToString();
                //info="发送失败,请检查发送失败的供应商的电子邮箱地址!";
                string msg = to + ": 发送失败!";
                writelog(msg);

            }
            return info;

        }
如果1个邮件地址不存在,请问怎么捕获这个异常,我捕获不了。 --------------------编程问答-------------------- 一个外部smtp服务器不需要验证
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,