Exemple #1
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        Userfac   objPass     = new Userfac();
        Mailfac   objSendMail = new Mailfac();
        DataTable dt          = new DataTable();

        if (objPass.UserExists(txtEmail.Text))
        {
            litError.Text = "";

            dt = objPass.GetUserByID(txtEmail.Text);

            var p = dt.Rows[0]["fldString"].ToString() + "&date=" + Convert.ToDateTime(dt.Rows[0]["fldDato"]).ToShortDateString();

            var b = "<img src='http://multimedia.pol.dk/archive/00866/Macaca_nigra_self-p_866791y.jpg' /><br /><h1>Reset dit password her!</h1>";
            var m = "<footer style='width:100%; height:100px; background-color:grey; position:absolute; bottom:0px;'><div style='text-align:center;'><a href='http://localhost:24244/Reset?id=" + p + "'>Reset Password</a></div></footer>";

            dt = objSendMail.GetEmailSys();

            objSendMail.SendMyMail(txtEmail.Text, dt.Rows[0]["fldEmail"].ToString(), b, m.ToString(), dt.Rows[0]["fldPassword"].ToString());
        }
        else
        {
            litError.Text = "<p style='color:red;'>Email eksistere ikke!</p>";
        }
    }
    protected void btnTilmeld_Click(object sender, EventArgs e)
    {
        if (objSendMail.EmailExists(txtTilmeld.Text))
        {
            litError.Text = "<p style='color:red;'>Email eksistere allerede!</p>";
        }
        else
        {
            Guid _ran = Guid.NewGuid();
            var  r    = _ran.ToString();

            objSendMail.InsertEmail(txtTilmeld.Text, r);

            var m = "<footer style='width:100%; height:100px; background-color:grey; position:absolute; bottom:0px;'><div style='text-align:center;'><a href='http://localhost:52255/unsubscribe-email?id=" + r + "'>send mig ikke flere emails</a></div></footer>";
            var b = "<img src='http://multimedia.pol.dk/archive/00866/Macaca_nigra_self-p_866791y.jpg' /><br /><h1>Tak for din tilmelding!</h1>";

            dt = objSendMail.GetEmailSys();

            objSendMail.SendMyMail(txtTilmeld.Text, dt.Rows[0]["fldEmail"].ToString(), b, m.ToString(), dt.Rows[0]["fldPassword"].ToString());

            txtTilmeld.Text = "";
            litError.Text   = "";
            //pnlSucces.Visible = true;
            litError.Text = "<p>Tak for din tilmelding!</p>";
        }
    }