예제 #1
0
        public ActionResult RecupSenha()
        {
            var RecS = new RecSenha();
            return View(RecS);

        }
예제 #2
0
        public string RecuperarSenha(String email, RecSenha ModelRecSenha)
        {
            String Qry;

            EmailService e_mail = new EmailService();
            SQLServer SQL = new SQLServer();
            SQL.ConectaDB();

            Qry = "select senhaUsuario from tblUsuario where emailUsuario = '" + email + "'";

            SqlDataReader Rs = SQL.DR(Qry);

            //encontrou o e-mail
            if (Rs.Read() == true)
            {

                ModelRecSenha.Senha = Rs["senhaUsuario"].ToString();

                bool retorno = SendSenha("*****@*****.**", email, "Sua senha", "AchadosPerdidos\n\nSua senha é: " + ModelRecSenha.Senha);

                // // Gmail Remetente
                //var fromAddress = "*****@*****.**";

                //// Email destino
                //var toAddress = "*****@*****.**";

                ////Senha do e-mail remetente
                //const string fromPassword = "******";

                //// Assunto
                //string subject = Assunto;

                //// Corpo do e-mail
                //string body = "De: " + Nome + "\n";
                //body += "Email: " + Email + "\n";
                //body += "Assunto: " + Assunto + "\n";
                //body += "Mensagem: \n" + Msg + "\n";

                //// smtp settings
                //var smtp = new System.Net.Mail.SmtpClient();
                //{
                //	smtp.Host = "smtp.gmail.com";
                //	smtp.Port = 587;
                //	smtp.EnableSsl = true;
                //	smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                //	smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
                //	smtp.Timeout = 20000;
                //}

                //// Realiza os envios.
                //smtp.Send(fromAddress, toAddress, subject, body);

                //retorno = e_mail.Send()

                if (retorno == false)
                {

                    ModelRecSenha.Result = "Não foi possível enviar a senha para o e-mail informado, tente novamente.";

                }
                else
                {

                    ModelRecSenha.Result = "Sua senha foi enviada para o e-mail informado.";
                }

            }

            return "Ok";
        }
예제 #3
0
        public ActionResult RecuperaSenha(string EmailID)
        {

            Usuario User = new Usuario();
            DisparaSenha disparaSenha = new DisparaSenha();
            RecSenha ModelRecSenha = new RecSenha();
            string Retorn;



            //valida se o e-mail informado existe.
            User.ValidaEmailRecSenha(EmailID, out Retorn);

            if (Retorn.Contains("ERRO") == false)
            {

                disparaSenha.RecuperarSenha(EmailID, ModelRecSenha);
                return View("RecupSenha", ModelRecSenha);

            }
            // não existe o e-mail informado
            else
            {
                ModelRecSenha.Result = Retorn;
                return View("RecupSenha", ModelRecSenha);

            }

        }