Example #1
0
        public ActionResult Details(correo email)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    usuario user = tabla.usuario(Convert.ToInt32(Session["idUsuario"]));
                    email.nombre     = user.getNom();
                    email.correo2    = user.getCor();
                    email.contrasena = user.getPas();

                    bool estado = tabla.enviar(email);

                    ModelState.AddModelError("", "Los correos fueron enviados.");

                    ViewBag.Script = "<script type='text/javascript'>alert('Mensaje');</script>";

                    return(RedirectToAction("Index"));
                }
                ModelState.AddModelError("", "Los correos NO fueron enviados.");
                return(View(email));
            }
            catch
            {
                ModelState.AddModelError("", "Los correos NO fueron enviados.");
                return(View(email));
            }
        }
        public async Task <ActionResult <correo> > Postemail(correo correo)
        {
            System.Net.Mail.MailMessage mmsg = new System.Net.Mail.MailMessage();
            mmsg.To.Add(correo.correo1);
            mmsg.Subject         = "Reporte Alumno Matricula: " + correo.matricula;
            mmsg.SubjectEncoding = System.Text.Encoding.UTF8;

            mmsg.Bcc.Add("*****@*****.**");

            mmsg.Body         = ("Estimado padre de familia su hijo: " + correo.nombre + " " + correo.descripcion + " Atte Profesor Omar ");
            mmsg.BodyEncoding = System.Text.Encoding.UTF8;
            mmsg.IsBodyHtml   = true;
            mmsg.From         = new System.Net.Mail.MailAddress("*****@*****.**");

            System.Net.Mail.SmtpClient cliente = new System.Net.Mail.SmtpClient();
            cliente.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Thor3432-");
            cliente.Port        = 587;
            cliente.EnableSsl   = true;
            cliente.Host        = "smtp.gmail.com";

            try
            {
                cliente.Send(mmsg);
            }
            catch (Exception ex)
            {
                return(Content("Error al eviar" + ex));
            }

            return(Content("Correo Enviado" + correo));
        }
Example #3
0
        //
        // GET: /plantilla/Details/5
        public ActionResult Details(int id)
        {
            plantillas nodo = tabla.plantillasGetEdit(id);

            if (nodo == null)
            {
                return(HttpNotFound());
            }
            correo email = new correo();

            email.idPlantilla = nodo.idPlantilla;
            email.mensaje     = nodo.mensaje;
            email.html        = nodo.html;

            return(View(email));
        }
    protected void B_enviar_Click(object sender, EventArgs e)
    {
        DAO_Usuarios dao = new DAO_Usuarios();

        System.Data.DataTable validez = dao.generarToken(int.Parse(TB_Recuperacion.Text));

        if (int.Parse(validez.Rows[0]["id"].ToString()) > 0)
        {
            EUserToken token = new EUserToken();
            token.Id     = int.Parse(validez.Rows[0]["id"].ToString());
            token.Estado = int.Parse(validez.Rows[0]["estado"].ToString());
            token.Correo = validez.Rows[0]["email"].ToString();
            token.Fecha  = DateTime.Now.ToFileTimeUtc();

            String userToken = encriptar(JsonConvert.SerializeObject(token));
            dao.almacenarToken(userToken, token.Id);

            correo correo = new correo();

            String mensaje = "su link de acceso es: " + "http://localhost:51068/View/RecuperarContraseña2.aspx?" + userToken;


            correo.enviarCorreo(token.Correo, userToken, mensaje);

            Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Su nueva contraseña ha sido enviada por correo');", true);
            TB_Recuperacion.Text = "";
        }
        else if (int.Parse(validez.Rows[0]["id"].ToString()) == -2)
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('Ya existe un token por favor verifique su correo');", true);
            TB_Recuperacion.Text = "";
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('El usuario digitado no existe');", true);
            TB_Recuperacion.Text = "";
        }

        //Page.ClientScript.RegisterStartupScript(GetType(), "msgbox", "alert('SE HA ENVIADO UN ENLACE A SU EMAIL');", true);
        //TB_Recuperacion.Text = "";
    }
Example #5
0
    protected void guardarUsuario_Click(object sender, EventArgs e)
    {
        String nombre    = this.txtNombre.Text;
        String apellido  = this.txtApellidos.Text;
        String correo    = this.txtCorreo.Text;
        String fecha     = this.txtFechaN.Text;
        String tel       = this.txtTelefono.Text;
        String direccion = this.txtDireccion.Text;
        String duracion  = this.txtContra.Text;
        String dui       = this.txtDui.Text;
        String fechai    = this.fechaInicio.Text;
        String fechaf    = this.fechaFin.Text;
        int    univ      = int.Parse(ddlUniversidades.SelectedValue);
        int    carr      = int.Parse(ddlCarreras.SelectedValue);
        int    nivel     = int.Parse(ddlNivel.SelectedValue);
        int    beca      = int.Parse(this.ddlPrograma.SelectedValue);

        if (nombre != "")
        {
            if (apellido != "")
            {
                if (correo != "" && fecha != "" && tel != "" && direccion != "" && dui != "" && fechai != "" && fechaf != "")
                {
                    if (beca > 0 && nivel > 0 && carr > 0 && univ > 0)
                    {
                        conexion conexionSQL = new conexion();
                        conexionSQL.conectar();
                        generadorContra c         = new generadorContra();
                        String          contra    = c.generarContra();
                        encriptacion    enc       = new encriptacion();
                        String          contraEnc = enc.encriptarContra(contra);
                        String          codB      = conexionSQL.getCodigoB(beca);
                        int             codigo    = conexionSQL.codigoMax() + 1;
                        this.metodoCodigo(codB, codigo);
                        int resp = conexionSQL.agregarBecario(nombre, apellido, correo, contra, univ, nivel, carr, beca, fecha, fechai, fechaf, tel, direccion, this.codigoB, dui, duracion);
                        conexionSQL.desconectar();
                        if (resp > 0)
                        {
                            correo enviarCo = new correo(correo, "Credeciales de Usuario", "Estimado/a: " + nombre + ". Su password es: " + contra);
                            if (enviarCo.Estado)
                            {
                                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true);
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true);
                            }
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
        }
    }
Example #6
0
 protected void guardarUsuario_Click(object sender, EventArgs e)
 {
     try
     {
         String nombre   = txtNombUsu.Text;
         String apellido = txtApelUsu.Text;
         String correo   = txtCorreUsu.Text;
         int    tipo     = int.Parse(ddlTipoUsu.SelectedValue);
         if (nombre != "")
         {
             if (apellido != "")
             {
                 if (correo != "")
                 {
                     if (tipo > 0)
                     {
                         conexion conexionSQL = new conexion();
                         conexionSQL.conectar();
                         generadorContra c         = new generadorContra();
                         String          contra    = c.generarContra();
                         encriptacion    enc       = new encriptacion();
                         String          contraEnc = enc.encriptarContra(contra);
                         int             resp      = conexionSQL.agregarUsuario(nombre, apellido, correo, contraEnc, tipo);
                         conexionSQL.desconectar();
                         if (resp > 0)
                         {
                             correo enviarCo = new correo(correo, "Credeciales de Usuario", "Estimado/a: " + nombre + ". Su password es: " + contra);
                             if (enviarCo.Estado)
                             {
                                 ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true);
                             }
                             else
                             {
                                 ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true);
                             }
                         }
                         else
                         {
                             ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                         }
                     }
                     else
                     {
                         ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                     }
                 }
                 else
                 {
                     ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
                 }
             }
             else
             {
                 ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
             }
         }
         else
         {
             ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true);
     }
 }