Esempio n. 1
0
 /// <summary>
 /// 得到系统设定的发送邮箱
 /// </summary>
 protected void GetSendMail()
 {
     ShowShop.BLL.SystemInfo.MailSetting bll = new ShowShop.BLL.SystemInfo.MailSetting();
     ShowShop.Model.SystemInfo.MailSetting model = bll.GetModel();
     if (model != null)
     {
         this.txtSendEmail.Text = model.MailId;
     }
 }
Esempio n. 2
0
 private void GetModel()
 {
     ShowShop.BLL.SystemInfo.MailSetting bll = new ShowShop.BLL.SystemInfo.MailSetting();
     Model.SystemInfo.MailSetting model = bll.GetModel();
     if(model!=null)
     {
         this.txtId.Value = model.Id.ToString();
         this.txtMailId.Text = model.MailId;
         this.txtMailPassword.Text = model.MailPassword;
         this.txtSmtpServerIP.Text = model.SmtpServerIP;
         this.txtSmtpServerPort.Text = model.SmtpServerPort.ToString();
     }
     model = null;
     bll = null;
 }
Esempio n. 3
0
 private void Save()
 {
     ShowShop.BLL.SystemInfo.MailSetting bll = new ShowShop.BLL.SystemInfo.MailSetting();
     Model.SystemInfo.MailSetting model = new ShowShop.Model.SystemInfo.MailSetting();
     try {
         if (txtMailId.Text.Trim()!="")
         {
             if (!ChangeHope.Common.ValidateHelper.IsEmail(txtMailId.Text.Trim()))
             {
                 this.ltlMsg.Text = "操作失败,请输入正确邮箱。";
                 this.pnlMsg.Visible = true;
                 this.pnlMsg.CssClass = "actionErr";
                 return;
             }
         }
         model.Id = ChangeHope.Common.StringHelper.StringToInt(this.txtId.Value);
         model.MailId = this.txtMailId.Text;
         model.MailPassword = this.txtMailPassword.Text;
         model.SmtpServerIP = this.txtSmtpServerIP.Text;
         model.SmtpServerPort = ChangeHope.Common.StringHelper.StringToInt(this.txtSmtpServerPort.Text);
         if (model.Id > 0)
         {
             bll.Update(model);
         }
         else
         {
             bll.Add(model);
         }
         this.ltlMsg.Text = "操作成功!";
         this.pnlMsg.CssClass = "actionOk";
         this.pnlMsg.Visible = true;
     }
     catch(Exception ex) {
         this.ltlMsg.Text = "操作失败"+ex.ToString();
         this.pnlMsg.Visible = true;
         this.pnlMsg.CssClass = "actionErr";
     }
     finally {
         bll = null;
         model = null;
     }
 }
Esempio n. 4
0
 protected void SendByType(string toAddr)
 {
     string server = string.Empty;
     string username = string.Empty;
     string password = string.Empty;
     string title = string.Empty;
     string content = string.Empty;
     ShowShop.BLL.SystemInfo.MailSetting bll = new ShowShop.BLL.SystemInfo.MailSetting();
     ShowShop.Model.SystemInfo.MailSetting model = bll.GetModel();
     if (model != null)
     {
         server = model.SmtpServerIP;
         username = model.MailId;
         password = model.MailPassword;
     }
     title = this.txtEmailTitle.Text.Trim();
     content = this.txtEmailContent.Value;
     SendEmail(server, username, password, toAddr, title, content);
 }
        private void SendEmail(string toaddr, string titel, string body)
        {
            ShowShop.BLL.SystemInfo.MailSetting mailBll = new ShowShop.BLL.SystemInfo.MailSetting();
            ShowShop.Model.SystemInfo.MailSetting mailModel = mailBll.GetModel();
            if (mailModel != null)
            {

                try
                {
                    MailMessage msg = new MailMessage();
                    //发送到
                    msg.To.Add(toaddr);
                    msg.From = new MailAddress(mailModel.MailId, titel, System.Text.Encoding.UTF8);
                    //标题
                    msg.Subject = titel;
                    msg.SubjectEncoding = System.Text.Encoding.UTF8;
                    //内容
                    msg.Body = body;
                    msg.BodyEncoding = System.Text.Encoding.UTF8;
                    msg.IsBodyHtml = true;
                    //优先级
                    msg.Priority = MailPriority.High;
                    SmtpClient client = new SmtpClient();
                    client.Credentials = new System.Net.NetworkCredential(mailModel.MailId, mailModel.MailPassword);
                    //Gmail邮箱发送  587
                    client.Port = 587;
                    client.Host = mailModel.SmtpServerIP;
                    client.EnableSsl = true;
                    client.Send(msg);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }