示例#1
0
        public static void SendEmail(Model_Email email, HttpServerUtility Server)
        {
            //Send email
            string sampleFilePathpath = Server.MapPath("/templates/email.html");

            using (var sr = new StreamReader(sampleFilePathpath))
            {
                var content = sr.ReadToEnd();

                MailMessage message = new MailMessage();
                message.From = new MailAddress("*****@*****.**");
                message.To.Add(email.email);
                message.Subject    = email.subject;
                message.IsBodyHtml = true;
                message.Body       = content.Replace("{{NAME}}", email.name).Replace("{{BODY}}", email.body);

                SmtpClient smtpClient = new SmtpClient();
                smtpClient.UseDefaultCredentials = true;

                smtpClient.Host = "apistacks.com";
                smtpClient.Port = 25;
                //smtpClient.EnableSsl = true;
                smtpClient.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Tawanda_91!");
                smtpClient.Send(message);
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["userID"] == null)
            {
                Response.Redirect("/Login");
            }

            txtPasswordError.Visible = false;

            if (Page.IsPostBack)
            {
                var payload = new
                {
                    firstName = txtFirstName.Value,
                    lastName  = txtLastName.Value,
                    business  = txtBusiness.Value,
                    phone     = txtPhone.Value,
                    website   = txtWebsite.Value
                };

                if (Global.db.WriteToDB("Users/" + Session["userID"], payload))
                {
                    UserSessionManager sessionMan = new UserSessionManager();
                    sessionMan.LoadUserInfo((User)Session["user"]);
                }

                //Reset password
                if (txtPasswordOld.Value.Trim() != "" && txtPasswordNew.Value.Trim() != "" && txtPasswordNewVerify.Value.Trim() != "")
                {
                    var oldPasword        = txtPasswordOld.Value.Trim();
                    var newPassword       = txtPasswordNew.Value.Trim();
                    var newPasswordVerify = txtPasswordNewVerify.Value.Trim();

                    if (newPassword != newPasswordVerify)
                    {
                        txtPasswordError.Visible   = true;
                        txtPasswordError.InnerText = "Passwords do not match";
                    }
                    else
                    {
                        var changedPassword = Global.db.ChangePassword(Session["userEmail"].ToString(), oldPasword, newPassword);
                        if (changedPassword == null)
                        {
                            txtPasswordError.Visible = true;
                        }
                    }
                }

                //Send Email
                var newEmail = new Model_Email
                {
                    email   = "*****@*****.**",
                    name    = "Patrick",
                    subject = "Settings have changed",
                    body    = "Thanks for creating an Landrick account. To continue, please confirm your email address by clicking the button below :"
                };
                EmailSender.SendEmail(newEmail, Server);
            }
            else
            {
                //Set current Values
                txtFirstName.Value = Session["userFirstName"].ToString();
                txtLastName.Value  = Session["userLastName"].ToString();
                txtEmail.Value     = Session["userEmail"].ToString();
                txtBusiness.Value  = Session["userBusiness"].ToString();
                txtPhone.Value     = Session["userPhone"].ToString();
                txtWebsite.Value   = Session["userWebsite"].ToString();
            }
        }