コード例 #1
0
        private void SendVerificationMail(string emailTo, string shortGuid)
        {
            //Guid guid = (Guid)user.ProviderUserKey;

            DRCOGConfig config = DRCOGConfig.GetConfig();
            string emailConfirmationPage = config.EmailConfirmationPage;

            string emailSubject = "DRCOG (T.R.I.P.S.) - Account Validation Email";
            string emailBody = "";
            string emailLink = emailConfirmationPage + shortGuid;

            //Make body of email
            //if (user.) emailBody = "<p>Dear " + firstName + ",</p>";
            emailBody = emailBody + "<p>Thank you for creating a T.R.I.P.S account. To activate your account " +
                " please click <a href=\"" + emailLink + "\">here</a>.</p>";
            emailBody = emailBody + "<p>After you have clicked on the link above, you will be able to sign " +
                "into the T.R.I.P.S. at www3.drcog.org/trips/.</p>";

            IEmailService mail = new EmailService()
            {
                Body = emailBody,
                Subject = emailSubject,
                To = emailTo
            };
            try
            {
                mail.Send("*****@*****.**", "DRCOG (TRIPS) Account Verification Service");
            }
            catch (Exception exc)
            {
                Exception exci = new Exception("Re/SendVerificationEmail; TO:" + emailTo, exc);
                Elmah.ErrorSignal.FromCurrentContext().Raise(exci);
            }
        }
コード例 #2
0
        public JsonResult ForgotPassword(PasswordRecoveryModel model)
        {
            ModelState.Remove("Answer");
            ModelState.Remove("Password");
            ModelState.Remove("ConfirmPassword");

            if (ModelState.IsValid)
            {
                try
                {
                    var user = _userRepository.GetUserByEmail(model.Email, false);

                    if (user == null)
                    {
                        return Json(new
                        {
                            data = false
                            ,
                            message = "The account requested does not exist. Please check your entry."
                            ,
                            error = "true"
                        });
                    }

                    DRCOGConfig config = DRCOGConfig.GetConfig();
                    string recoverypage = config.PasswordRecoveryPage;
                    string changepasswordpage = config.ChangePasswordBaseUrl;

                    string newPassword = _userRepository.ResetPassword(user.PersonGUID);
                    IEmailService mail = new EmailService()
                    {
                        Body = "<h1>Password Recovery was Requested!</h1>" +
                            "Your new password is now set to:<br/><br/><b>" + newPassword + "</b><br/><br />" +
                            "-------------------------------------------------------------------<br/>" +
                            "<u><b>What do I do now?</b></u><br/>" +
                            "1. Copy the above password<br/>" +
                            "2. Login with the password OR Follow this link to change your password: "******"<a href=\"" + changepasswordpage + user.PersonShortGuid + "\">Change your Password</a>",
                        Subject = "DRCOG (T.R.I.P.S.) - Password Recovery email",
                        To = model.Email
                    };

                    mail.Send("*****@*****.**", "DRCOG (TRIPS) Password Recovery Service");
                    return Json(new
                    {
                        data = "Password Changed"
                        ,
                        message = "Please check your email and click on the link to reset your password."
                        ,
                        error = "false"
                    });

                }
                catch (Exception exc)
                {
                    Exception exci = new Exception("ForgotPassword; TO:" + model.Email, exc);
                    Elmah.ErrorSignal.FromCurrentContext().Raise(exci);

                    return Json(new
                    {
                        message = "There was an error sending your password email."
                        ,
                        error = "true"
                        ,
                        exceptionMessage = exc.Message
                    });
                }

            }

            return Json(new
            {
                message = "Changes could not be stored. An error has been logged."
                ,
                error = "true"
                ,
                exceptionMessage = String.Empty
            });
        }
コード例 #3
0
        public JsonResult SendPrintVerification(string sponsorName)
        {
            //DRCOGConfig config = DRCOGConfig.GetConfig();
            //string emailConfirmationPage = config.EmailConfirmationPage;

            // who to send it too?

            string emailTo = "*****@*****.**";
            string emailSubject = "[TRIPS-Survey] " + sponsorName + " Certification Printed";
            string emailBody = "";

            //Make body of email
            emailBody += (new CultureInfo("en-US", false).TextInfo).ToTitleCase(sponsorName.ToLower()) +
                " has printed it's Transportation Improvement Survey Certification letter." +
                " The Certification letter will be mailed once it has be signed.";

            IEmailService mail = new EmailService()
            {
                Body = emailBody,
                Subject = emailSubject,
                To = emailTo
            };
            try
            {
                mail.Send();
            }
            catch (Exception exc)
            {
                Exception exci = new Exception("Re/SendVerificationEmail; TO:" + emailTo, exc);
                Elmah.ErrorSignal.FromCurrentContext().Raise(exci);

                return Json(new
                {
                    message = "E-mail notification was not successful. An error has been logged."
                    ,
                    error = "true"
                    ,
                    exceptionMessage = exc.Message
                });
            }
            return Json(new
            {
                message = "Changes were successful."
                ,
                error = "false"
            });
        }