public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.Email);

                if (user == null || !(await UserManager.IsEmailConfirmedAsync(user.Id)))
                {
                    ModelState.AddModelError("", "The user either does not exist or is not confirmed.");
                    return(View());
                }


                //Start of code by Tom
                //var provider = new Microsoft.Owin.Security.DataProtection.DpapiDataProtectionProvider("MyApp") ;

                //UserManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>
                //(provider.Create("EmailConfirmation"));


                //End of code by Tom

                // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                // Send an email with this link
                string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id);

                //string code = UserManager.GeneratePasswordResetToken(user.Id);

                var callbackUrl = Url.Action("ResetPassword", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);

                //await UserManager.SendEmailAsync(user.Id, "Reset Password", "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>");

                ////Start of code changes by tom to send password reset
                System.Net.Mail.MailMessage mailMessage = new MailMessage();
                // mailMessage.From = new MailAddress("*****@*****.**");
                mailMessage.To.Add(new MailAddress("*****@*****.**"));

                System.Net.Mail.SmtpClient client = new SmtpClient();



                mailMessage.Body    = "Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>";
                mailMessage.Subject = "Reset password";

                client.Send(mailMessage);

                //end of code by tom to send password reset.

                return(RedirectToAction("ForgotPasswordConfirmation", "Account"));
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }