Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = PagesTitles.ManagerEmailNotificationEdit + BackendHelper.TagToValue("page_title_part");
            OtherMethods.ActiveRightMenuStyleChanche("hlEmailNotifications", this.Page);
            OtherMethods.ActiveRightMenuStyleChanche("hlContent", this.Page);

            #region Блок доступа к странице
            var userInSession = (Users)Session["userinsession"];
            var rolesList     = Application["RolesList"] as List <Roles>;
            var currentRole   = (Roles)rolesList.SingleOrDefault(u => u.Name.ToLower() == userInSession.Role.ToLower());
            if (currentRole.PageEmailNotificationsEdit != 1)
            {
                Response.Redirect("~/Error.aspx?id=1");
            }
            #endregion

            if (Page.Request.Params["id"] != null)
            {
                var mail = new EmailNotifications {
                    ID = Convert.ToInt32(Page.Request.Params["id"])
                };
                mail.GetById();
                if (!IsPostBack)
                {
                    if (string.IsNullOrEmpty(mail.Title))
                    {
                        tbTitle.Visible  = false;
                        lblTitle.Visible = false;
                    }
                    tbTitle.Text            = mail.Title;
                    tbBody.Text             = mail.Body;
                    lblDescriptionMore.Text = mail.Description;
                }
            }
        }
Ejemplo n.º 2
0
        public static void MailSend(Int32 mailId, String emailTo, String replaceThis, String replaceWithThat)
        {
            var message = new MailMessage
            {
                From = new MailAddress(MainEmail, NotOfficialName)
            };

            message.ReplyToList.Add(new MailAddress(MainEmail, NotOfficialName));
            message.To.Add(new MailAddress(emailTo));
            var mail = new EmailNotifications()
            {
                ID = mailId
            };

            mail.GetById();
            if (!String.IsNullOrEmpty(replaceThis) && !String.IsNullOrEmpty(replaceWithThat))
            {
                message.Subject = mail.Title.Replace(replaceThis, replaceWithThat);
                message.Body    = mail.Description.Replace(replaceThis, replaceWithThat);
            }
            else
            {
                message.Subject = "[" + BackendHelper.TagToValue("server_name") + "] " + mail.Title;
                message.Body    = mail.Description;
            }

            client.Send(message);
        }