SendMail函数在Mail.cs中public static string SendMail(string to, string from, string subject, 
        string body, string attach, string cc,  bool useHtmlFormat)
  {
        if (Global.systemSetting.MailServer == "")
return "发送邮件失败!没有配置邮件服务器。";        MailMessage mailMsg = new MailMessage();
        mailMsg.To = to;
        mailMsg.BodyEncoding = Encoding.UTF8;
                                
        if (Global.systemSetting.SenderMail.Length < 1)
            mailMsg.From = "[email protected]";
        else
            mailMsg.From = Global.systemSetting.SenderMail;
            
            mailMsg.Subject = subject;
            mailMsg.Body = body;
            if (attach != null && attach != "" )
            {
                    char[] delim = new char[] {','};
                    foreach (string sSubstr in attach.Split(delim))
                    {
                            MailAttachment MyAttachment = new MailAttachment(sSubstr);
                            mailMsg.Attachments.Add(MyAttachment);
                    }
            }            mailMsg.Cc = cc;
            if (useHtmlFormat)
                    mailMsg.BodyFormat = MailFormat.Html;
            else
                    mailMsg.BodyFormat = MailFormat.Text;                           
            
            if (Global.systemSetting.RequireSmtpAuthentication)
            {
                    mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
                    mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",Global.systemSetting.MailUsername);
                    mailMsg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",Global.systemSetting.MailPassword);
            }
            
            SmtpMail.SmtpServer = Global.systemSetting.MailServer;            try
            {                    SmtpMail.Send(mailMsg);
                    return "发送邮件成功(CDO)。";
            }
            catch(Exception ex)
            {
                    Exception source = ex;
                    while (source.InnerException != null)
                            source = source.InnerException;                    return "发送邮件失败(CDO)!错误信息:" + source.Message ;
            }       
  }

解决方案 »

  1.   

    catch(Exception ex)
                {
                        Exception source = ex;
                        while (source.InnerException != null)
                                source = source.InnerException;                    return "发送邮件失败(CDO)!错误信息:" + source.Message ;
                }       我想知道,在这里应该接下去如何处理啊,将没有发送成功的邮件下次自动重新发送,好心人能不能给出代码啊,新人感激不尽
      

  2.   

    http://blog.csdn.net/Wgf2006/archive/2007/02/03/1501935.aspx