//发送系统邮件 public static bool SendSystemEmail(string sendnumber, string sendrole, string content, string recivenumber) { MessageSendModel messagesend = new MessageSendModel(); //邮件保存 messagesend.Content = content; messagesend.DropFlag = 0; messagesend.InfoTitle = "系统邮件"; messagesend.LoginRole = "2"; messagesend.ReadFlag = 0; messagesend.Sender = sendnumber; messagesend.SenderRole = "2"; messagesend.LanguageCode = "L001"; messagesend.CountryCode = "1"; messagesend.MessageType = 'm'; messagesend.Receive = recivenumber; messagesend.SetNoCondition(); bool bb = MessageSendBLL.Addsendaffiche(messagesend); HttpContext.Current.Session["EmailCount"] = AjaxClass.GetNewEmailCount( ); return(bb); }
protected void btn_Save_Click(object sender, EventArgs e) { #region 验证用户输入 if (Request["type"] != "huifu" && txtBianhao.Text.Trim() == "" && this.RadioBianhao.Checked) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert(\"" + GetTran("001607", "请输入收件人编号") + "!!!\");</script>"); return; } if (txtTitle.Text.Trim() == "") { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("001609", "请输入标题") + "!!!');</script>"); Literal1.Text = ""; return; } if (this.content1.Value.Trim().Length.Equals(0)) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("kwl", "请输入邮件内容") + "!!!');</script>"); return; } if (this.content1.Value.Trim().Length > 4000) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("000863", "您输入的信息过长") + "!!!');</script>"); return; } double from = 0; double to = 0; if (this.RadioRange.Checked && this.ChkBonus.Checked) { try { from = Convert.ToDouble(this.TxtBonusFrom.Text.Trim()); to = Convert.ToDouble(this.TxtBonusTo.Text.Trim()); } catch { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("kwl", "您输入的奖金区间无效") + "!!!');</script>"); return; } if (from >= to) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("kwl", "您输入的奖金区间无效") + "!!!');</script>"); return; } } if (this.drop_LoginRole.SelectedValue.Equals("2") && this.RadioRange.Checked && this.ChkNet.Checked) { if (this.TxtLeader.Text.Trim().Length.Equals(0)) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("kwl", "请指定团队首领编号") + "!!!');</script>"); return; } else { if (!MessageSendBLL.CheckNumber(2, this.TxtLeader.Text.Trim())) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("kwl", "指定的团队首领不存在") + "!!!');</script>"); return; } } } #endregion StringBuilder sb = new StringBuilder(); //if (Request["type"] != null) //{ if (Request["type"] == "huifu") { MessageSendModel messagesend = new MessageSendModel(); //邮件保存 messagesend.Content = this.content1.Value.Trim(); messagesend.DropFlag = 0; messagesend.InfoTitle = txtTitle.Text.Trim().Replace("<", "<").Replace(">", ">"); messagesend.LoginRole = drop_LoginRole.SelectedItem.Value; messagesend.ReadFlag = 0; messagesend.Sender = Session["Company"].ToString(); messagesend.SenderRole = "0"; messagesend.LanguageCode = this.DropDownList2.SelectedValue; messagesend.CountryCode = this.DropDownList1.SelectedValue; messagesend.MessageType = 'm'; messagesend.SetNoCondition(); int hfid; try { hfid = Convert.ToInt32(Request["hfid"]); if (hfid < 0) { return; } } catch (Exception) { return; } messagesend.ReplyFor = hfid; System.Data.SqlClient.SqlDataReader dr = DAL.DBHelper.ExecuteReader("select Sender,ClassID from MessageReceive where ID=@id", new System.Data.SqlClient.SqlParameter("@id", hfid), CommandType.Text); if (dr.Read()) { messagesend.Receive = dr["Sender"].ToString(); messagesend.MessageClassID = Convert.ToInt32(dr["ClassID"]); } else { ScriptHelper.SetAlert(Page, GetTran("001589", "对不起发件人不存在") + "!!!"); return; } if (MessageSendBLL.Addsendaffiche(messagesend)) { string href = "ManageMessage_Recive.aspx" + (Request["ClassID"] == null ? "" : "?ClassID=" + Request["ClassID"]); ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("001587", "邮件回复成功") + "!!!');location.href='" + href + "';</script>"); } else { ScriptHelper.SetAlert(Page, GetTran("001588", "邮件回复失败") + "!!!"); } } else//信息 { if (Request["Id"] != null) { int id = Convert.ToInt32(Request["Id"]); //还没改 MessageSendBLL.DelMessageSendById(id); sb.Append(GetTran("001590", "邮件修改")); } else { Response.Cache.SetExpires(DateTime.Now); Permissions.CheckManagePermission(EnumCompanyPermission.ManageMessage); sb.Append(GetTran("001592", "邮件发送")); } MessageSendModel messagesend = new MessageSendModel(); //邮件保存 messagesend.Content = this.content1.Value.Trim(); messagesend.DropFlag = 0; messagesend.InfoTitle = txtTitle.Text.Trim().Replace("<", "<").Replace(">", ">"); messagesend.LoginRole = drop_LoginRole.SelectedItem.Value; messagesend.ReadFlag = 0; messagesend.Sender = Session["Company"].ToString(); messagesend.SenderRole = "0"; messagesend.LanguageCode = this.DropDownList2.SelectedValue; messagesend.CountryCode = this.DropDownList1.SelectedValue; messagesend.Qishu = CommonDataDAL.getMaxqishu(); messagesend.MessageType = 'm'; messagesend.SetNoCondition(); if (this.RadioBianhao.Checked) //指定了编号 { if (txtBianhao.Text.Trim().Length > 0) { if (!txtBianhao.Text.Trim().Equals("*")) { //验证编号是否存在 string[] strArray = txtBianhao.Text.Trim().Split(new char[] { ',' }); foreach (string strNO in strArray) { if (strNO != "") { int id = Convert.ToInt32(drop_LoginRole.SelectedValue); //验证编号是否存在 if (!MessageSendBLL.CheckNumber(id, strNO)) { Response.Write("<script>alert('" + strNO + GetTran("001584", "不存在") + "');</script>"); return; } } } } } else { ScriptHelper.SetAlert(Page, GetTran("001594", "请输入收件人") + "!!!"); return; } messagesend.Receive = DisposeString.DisString(txtBianhao.Text.Trim()); } else //指定了Range { messagesend.Receive = "*"; //if (this.ChkLevel.Checked) //{ // messagesend.ConditionLevel = Convert.ToInt16(this.DropLevel.SelectedValue); //} if (this.ChkBonus.Checked) { messagesend.ConditionBonusFrom = Convert.ToDouble(this.TxtBonusFrom.Text.Trim()); messagesend.ConditionBonusTo = Convert.ToDouble(this.TxtBonusTo.Text.Trim()); } if (this.ChkNet.Checked) { messagesend.ConditionRelation = Convert.ToChar(this.DropRelation.SelectedValue); messagesend.ConditionLeader = this.TxtLeader.Text.Trim(); } } if (MessageSendBLL.Addsendaffiche(messagesend)) { sb.Append(GetTran("001600", "成功") + "!!!"); ScriptHelper.SetAlert(Page, sb.ToString()); } else { sb.Append(GetTran("001541", "失败") + "!!!"); ScriptHelper.SetAlert(Page, sb.ToString()); } } this.txtTitle.Text = ""; this.TextBox1.Text = ""; this.content1.Value = ""; }