Ejemplo n.º 1
0
        public JsonResult ResetPassword(string Email)
        {
            bool result = false;
            var  user   = new UserData().ResetPassword(Email);

            if (user != null)
            {
                //Read Template and send email
                string        path = Server.MapPath("/Templates");
                StringBuilder sb   = new StringBuilder(System.IO.File.ReadAllText(path + @"/ResetPassword.html"));
                sb.Replace("!!!FirstName!!!", user.FirstName)
                .Replace("!!!Surname!!!", user.Surname)
                .Replace("!!!Password!!!", new DataEncryption().Decrypt(user.Password));

                //Audit
                result = new UserData().InsertUser(user);
                //Save Audit Details
                auditModel = new AuditModel
                {
                    ActivityDescription = "Your password was reset",
                    AuditDate           = DateTime.Now,
                    UserID = user.UserID
                };

                result = new AuditData().InsertAudit(auditModel);

                //Test Email TODO: Remove
                user.Email = "*****@*****.**";

                Domain.Model.Utilities.Email email = new Domain.Model.Utilities.Email
                {
                    Attachment    = null,
                    EmailMessage  = sb.ToString(),
                    FromAddress   = "*****@*****.**",
                    HasAttachment = false,
                    Subject       = "Password Reset",
                    ToEmail       = new List <string> {
                        user.Email
                    }
                };

                result = new Utilities.Mail.Email().SendEmail(email);
            }

            return(Json(result));
        }
Ejemplo n.º 2
0
        public JsonResult SendContactEmail(string FirstName, string Surname, string EmailAddress, string ContactNo, string Message)
        {
            //Get Template
            string path   = Server.MapPath("/Templates");
            bool   result = true;

            try
            {
                StringBuilder sb = new StringBuilder(System.IO.File.ReadAllText(path + @"/EmailTemplate.html"));
                sb.Replace("!!!FirstName!!!", FirstName)
                .Replace("!!!Surname!!!", Surname)
                .Replace("!!!Email!!!", EmailAddress)
                .Replace("!!!ContactNo!!!", ContactNo)
                .Replace("!!!Message!!!", Message);

                //Send email
                Domain.Model.Utilities.Email email = new Domain.Model.Utilities.Email
                {
                    Attachment    = null,
                    EmailMessage  = sb.ToString(),
                    FromAddress   = "*****@*****.**",
                    HasAttachment = false,
                    Subject       = "New Information Request",
                    ToEmail       = new List <string> {
                        "*****@*****.**"
                    }
                };



                result = new Utilities.Mail.Email().SendEmail(email);
            }
            catch (Exception ex)
            {
                string str = ex.Message;
            }


            return(Json(result));
        }