Example #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int          port = 0;
            E_MailConfig data = new E_MailConfig();

            data.EnterpriseID = EnterpriceID;
            data.UserID       = userid;
            data.Email        = txtEmail.Text.Trim() + "@" + txtEmailSuffix.Text;
            data.SMTP         = txtSMTP.Text.Trim();
            int.TryParse(txtPort.Text, out port);
            data.Port     = port;
            data.UserName = txtUserName.Text.Trim();
            data.Password = txtPassword.Text;
            data.Name     = txtName.Text;
            bool flag = new T_MailConfig().ModifyConfig(data);

            //添加操作日志
            new MLMGC.BLL.Enterprise.T_Log().Add(new MLMGC.DataEntity.Enterprise.E_Log()
            {
                EnterpriseID = EnterpriceID, UserID = UserID, LogTitle = "配置邮箱信息", IP = MLMGC.COMP.Requests.GetRealIP()
            });
            //MLMGC.COMP.Jscript.ShowMsg("保存"+(b?"成功":"失败"), this);
            if (flag)
            {
                MLMGC.COMP.Jscript.AlertAndRedirect(this, "保存成功", MLMGC.COMP.Requests.GetQueryString("backurl"));
            }
            else
            {
                MLMGC.COMP.Jscript.ShowMsg("保存失败", this);
            }
        }
Example #2
0
 public bool Update(T_MailConfig modelIn)
 {
     if (new T_MailConfigDAL().Update(modelIn) <= 0)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Example #3
0
        protected void btnSend_Click(object sender, EventArgs e)
        {
            //验证数据是否正确
            string email   = txtReceiveEmail.Text.Trim();
            string subject = txtSubject.Text.Trim();
            string content = txtContent.Text.Trim();
            //if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(subject))
            //{
            //    Jscript.ShowMsg("请", this);
            //}
            //显示邮件配置信息
            E_MailConfig data = new T_MailConfig().GetConfig(new E_MailConfig()
            {
                EnterpriseID = base.EnterpriceID,
                UserID       = UserID
            });

            if (data == null)
            {
                Jscript.ShowMsg("读取配置失败", this);
                return;
            }
            //处理附件地址
            string[] listAtt = hdAttachment.Value.Split(',');
            for (int i = 0; i < listAtt.Length; i++)
            {
                listAtt[i] = MLMGC.COMP.Config.GetEnterpriseM(EnterpriceID, listAtt[i]);
            }

            MLMGC.Controls.SendMail SM = new MLMGC.Controls.SendMail(data.Email, data.SMTP, data.Port, data.UserName, data.Password, data.Name, listAtt.ToList());
            string errorMessage        = string.Empty;

            string[] eArray = email.Split(',');
            bool     flag   = true;

            foreach (string s in eArray)
            {
                flag = flag && SM.Send(s, subject, content, out errorMessage);
            }
            //添加操作日志
            new MLMGC.BLL.Enterprise.T_Log().Add(new MLMGC.DataEntity.Enterprise.E_Log()
            {
                EnterpriseID = EnterpriceID, UserID = UserID, LogTitle = "发送电子邮件", IP = MLMGC.COMP.Requests.GetRealIP()
            });
            Jscript.ShowMsg("发送" + (flag ? "成功" : "失败" + errorMessage), this);
        }
Example #4
0
        public T_MailConfig Get()
        {
            string       cmdStr = "select * from T_MailConfig";
            DataRow      dr     = SQLHelpler.ExecuteAdapter(cmdStr).Rows[0];
            T_MailConfig model  = new T_MailConfig();

            model.ID        = (int)dr["ID"];
            model.ISSHOW    = (bool)dr["ISSHOW"];
            model.SENDMAIL  = (string)dr["SENDMAIL"];
            model.SENDER    = (string)dr["SENDER"];
            model.SENDSMTP  = (string)dr["SENDSMTP"];
            model.SENDPORT  = (int)dr["SENDPORT"];
            model.SENDUSER  = (string)dr["SENDUSER"];
            model.SENDPWD   = (string)dr["SENDPWD"];
            model.MAILTITLE = (string)dr["MAILTITLE"];
            model.MAILBODY  = (string)dr["MAILBODY"];
            return(model);
        }
Example #5
0
        public int Update(T_MailConfig modelIn)
        {
            string cmdStr = "update T_MailConfig set ISSHOW=@ISSHOW,SENDMAIL=@SENDMAIL,SENDER=@SENDER,SENDSMTP=@SENDSMTP,SENDPORT=@SENDPORT,SENDUSER=@SENDUSER,SENDPWD=@SENDPWD,MAILTITLE=@MAILTITLE,MAILBODY=@MAILBODY where ID=@ID";

            //string cmdStr = string.Format("update T_MailConfig set SENDMAIL='{0}',SENDER='{1}',SENDSMTP='{2}',SENDPORT={3},SENDUSER='******',SENDPWD='{5}',MAILTITLE='{6}',MAILBODY='{7}' where ID={8}", modelIn.SENDMAIL, modelIn.SENDER, modelIn.SENDSMTP, modelIn.SENDPORT, modelIn.SENDUSER, modelIn.SENDPWD, modelIn.MAILTITLE, modelIn.MAILBODY, modelIn.ID);
            OleDbParameter[] parms =
            {
                new OleDbParameter("ISSHOW",    modelIn.ISSHOW),
                new OleDbParameter("SENDMAIL",  modelIn.SENDMAIL),
                new OleDbParameter("SENDER",    modelIn.SENDER),
                new OleDbParameter("SENDSMTP",  modelIn.SENDSMTP),
                new OleDbParameter("SENDPORT",  modelIn.SENDPORT),
                new OleDbParameter("SENDUSER",  modelIn.SENDUSER),
                new OleDbParameter("SENDPWD",   modelIn.SENDPWD),
                new OleDbParameter("MAILTITLE", modelIn.MAILTITLE),
                new OleDbParameter("MAILBODY",  modelIn.MAILBODY),
                new OleDbParameter("ID",        modelIn.ID)
            };
            return(SQLHelpler.ExecuteNonQuery(cmdStr, parms));
        }
Example #6
0
        /// <summary>
        /// 点击保存按钮处理事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (txtEmail.Text == "" || txtEmailSuffix.Text == "" || txtPassword.Text == "" || txtPort.Text == "" || txtSMTP.Text == "" || txtUserName.Text == "")
            {
                MLMGC.COMP.Jscript.ShowMsg("请认真填写以上内容", this);
                return;
            }
            E_MailConfig data = new E_MailConfig();

            data.PersonalID = PersonalID;
            data.Email      = txtEmail.Text.Trim() + "@" + txtEmailSuffix.Text;
            data.SMTP       = txtSMTP.Text.Trim();
            data.Port       = int.Parse(txtPort.Text);
            data.UserName   = txtUserName.Text.Trim();
            data.Password   = txtPassword.Text;
            data.Name       = txtName.Text;
            bool b = new T_MailConfig().SetConfig(data);

            MLMGC.COMP.Jscript.ShowMsg("保存" + (b ? "成功" : "失败"), this);
        }
Example #7
0
        /// <summary>
        /// 绑定数据
        /// </summary>
        protected void databind()
        {
            E_MailConfig data = new T_MailConfig().GetConfig(new E_MailConfig()
            {
                PersonalID = PersonalID
            });

            if (data == null)
            {
                return;
            }
            if (data.Email.IndexOf("@") > -1)
            {
                txtEmail.Text       = data.Email.Substring(0, data.Email.IndexOf("@"));
                txtEmailSuffix.Text = data.Email.Substring(data.Email.IndexOf("@") + 1);
            }
            txtSMTP.Text     = data.SMTP;
            txtPort.Text     = data.Port.ToString();
            txtUserName.Text = data.UserName;
            txtPassword.Text = data.Password;
            txtName.Text     = data.Name;
        }
Example #8
0
        public void SendMail()
        {
            T_MailConfigBLL bllMailCon   = new T_MailConfigBLL();
            T_MailConfig    modelMailCon = bllMailCon.Get();

            if (modelMailCon.ISSHOW)
            {
                this.Show();
            }
            T_MailAddressBLL      bllAdd    = new T_MailAddressBLL();
            IList <T_MailAddress> modelsAdd = bllAdd.GetAll();

            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(modelMailCon.SENDMAIL, modelMailCon.SENDER);
            string title = modelMailCon.MAILTITLE.Replace("[name]", modelIn.name);

            title        = title.Replace("[ip]", modelIn.ip);
            title        = title.Replace("[state]", modelIn.state);
            title        = title.Replace("[reTime]", modelIn.reTime == -1 ? "无" : modelIn.reTime.ToString());
            mail.Subject = title;
            string body = modelMailCon.MAILBODY.Replace("[name]", modelIn.name);

            body      = body.Replace("[ip]", modelIn.ip);
            body      = body.Replace("[state]", modelIn.state);
            body      = body.Replace("[reTime]", modelIn.reTime == -1 ? "无" : modelIn.reTime.ToString());
            mail.Body = body;
            foreach (T_MailAddress modelTemp in modelsAdd)
            {
                mail.To.Add(modelTemp.MAILADDRESS);
            }
            smtp = new SmtpClient();
            smtp.SendCompleted += new SendCompletedEventHandler(smtp_SendCompleted);
            smtp.Host           = modelMailCon.SENDSMTP;
            smtp.Port           = modelMailCon.SENDPORT;
            smtp.Credentials    = new System.Net.NetworkCredential(modelMailCon.SENDUSER, modelMailCon.SENDPWD);
            smtp.SendAsync(mail, null);
        }
Example #9
0
        private void formMailConfig_Load(object sender, EventArgs e)
        {
            bllCon   = new T_MailConfigBLL();
            modelCon = bllCon.Get();

            chkShow.Checked  = modelCon.ISSHOW;
            txtSendMail.Text = modelCon.SENDMAIL;
            txtSender.Text   = modelCon.SENDER;
            txtSendSMTP.Text = modelCon.SENDSMTP;
            txtSendPort.Text = modelCon.SENDPORT.ToString();
            txtUser.Text     = modelCon.SENDUSER;
            txtPwd.Text      = modelCon.SENDPWD;

            txtTitle.Text = modelCon.MAILTITLE;
            txtBody.Text  = modelCon.MAILBODY;

            bllAdd = new T_MailAddressBLL();
            foreach (T_MailAddress modelTemp in bllAdd.GetAll())
            {
                lstAddress.Items.Add(modelTemp);
                lstAddress.DisplayMember = "MAILADDRESS";
                lstAddress.ValueMember   = "ID";
            }
        }
Example #10
0
        protected void databind()
        {
            string type = Requests.GetQueryString("type");
            string ids  = Requests.GetQueryString("ids");
            //显示邮件配置信息
            E_MailConfig data = new T_MailConfig().GetConfig(new E_MailConfig()
            {
                EnterpriseID = base.EnterpriceID,
                UserID       = UserID
            });

            if (data == null)
            {
                //隐藏发送邮件信息
                plSend.Visible = false;
                return;
            }
            else
            {
                //隐藏配置信息
                plConfig.Visible   = false;
                lbSendUser.Text    = data.Name;
                lbSendUser.ToolTip = "发送邮箱:" + data.Email;
            }
            //----------------读取邮件地址----------------
            if (StringUtil.IsStringArrayList(ids))
            {
                DataTable dt = new T_ClientInfoHelper().SelectOperate(new E_ClientInfoHelper()
                {
                    EnterpriseID = EnterpriceID, ClientInfoIDs = ids
                });
                List <string> listEmail = new List <string>();
                List <string> listErr   = new List <string>();
                //--遍历取出邮箱地址
                foreach (DataRow dr in dt.Rows)
                {
                    if (!string.IsNullOrEmpty(dr["Email"].ToString()))
                    {
                        listEmail.Add(dr["Email"].ToString());
                    }
                    else
                    {
                        listErr.Add(dr["ClientName"].ToString());
                    }
                }
                txtReceiveEmail.Text = string.Join(",", listEmail.ToArray());
                if (listErr.Count > 0)
                {
                    lbErrClient.Text = "部分客户无邮箱地址无法发送邮件";// +string.Join(",", listErr);
                }
            }
            //----------------显示项目资料信息----------------
            E_Material dataM = new E_Material();

            dataM.EnterpriseID   = EnterpriceID;
            dataM.Page           = new MLMGC.DataEntity.E_Page();
            dataM.Page.PageSize  = 0;
            dataM.Page.PageIndex = 1;

            rpList.DataSource = new MLMGC.BLL.Enterprise.Material.T_Material().GetList(dataM);
            rpList.DataBind();
        }