Пример #1
0
    protected void BtnSend_Click(object sender, EventArgs e)
    {
        MailManage mailManage = new MailManage();

        if (!mailManage.isAllowSize(this._strSenderCode))
        {
            this.Page.RegisterStartupScript("warn", "<script language=\"JavaScript\">alert('该邮件的附件总大小已经超过10M限制,请进行处理,否则该邮件无法发送!');</script>");
            return;
        }
        string text  = this.Session["HumanCode"].ToString() + this.Session["HumanCode2"].ToString() + this.Session["HumanCode3"].ToString();
        string text2 = this.hf.Value.ToString();
        string text3 = this.TBoxTitle.Text.ToString();

        if (text3.Trim() == "")
        {
            text3 = "---";
        }
        string strContent = this.TBoxContent.Text.ToString().Replace("\r\n", "").Replace("'", "''");
        int    iSms;

        if (this.CBoxSMS.Checked)
        {
            iSms = 1;
        }
        else
        {
            iSms = 0;
        }
        int rtx;

        if (this.CBRTX.Checked)
        {
            rtx = 1;
        }
        else
        {
            rtx = 0;
        }
        string text4 = "";

        text2 = this.Session["HumanName"].ToString() + this.Session["HumanName2"].ToString() + this.Session["HumanName3"].ToString();
        string[] array = text.Split(new char[]
        {
            '!'
        });
        string[] array2 = text2.Split(new char[]
        {
            ','
        });
        if (text.Length == 0)
        {
            this.RegisterClientScriptBlock("warn", "<SCRIPT language=\"JavaScript\">alert('收件人不能为空!')</SCRIPT>");
            return;
        }
        if (!mailManage.SendMail(this._iSysID, this._strSenderCode, this._strSenderName, DateTime.Now, text3, strContent, iSms, array, array2, this.iMailType, this.Session["HumanName"].ToString(), this.Session["HumanName2"].ToString(), rtx))
        {
            text4 += "向本系统发送邮件失败\\n";
        }
        if (this.CBoxSend.Checked)
        {
            text2 = this.Session["HumanName"].ToString();
            text  = this.Session["HumanCode"].ToString();
            if (!mailManage.SaveToOut(this._iSysID, this._strSenderCode, this._strSenderName, text3, strContent, text, text2, this.iMailType, this.Session["HumanName"].ToString(), this.Session["HumanName2"].ToString()))
            {
                text4 += "将邮件保存到发件箱出错!";
            }
        }
        if (text4 != "")
        {
            this.RegisterClientScriptBlock("warn", "<SCRIPT language=\"JavaScript\">alert('" + text4 + "');</SCRIPT>");
            return;
        }
        mailManage.AddlatelyLinkman(this.Session["yhdm"].ToString(), array, array2);
        base.Server.Transfer("viewmail_2.aspx");
        this.TreeView1.Nodes.Clear();
        this.bindtree();
        mailManage.AddlatelyLinkman(this.Session["yhdm"].ToString(), array, array2);
    }