Пример #1
0
        public JsonResult EnviarCorreo(ContactoViewModel model)
        {
            var rm = new ResponseModel();

            if (ModelState.IsValid)
            {
                try
                {
                    var _usuario = usuario.Obtener(FrontOfficeStartUp.UsuarioVisualizando());

                    var mail = new MailMessage();
                    mail.From = new MailAddress(model.Correo, model.Nombre);
                    mail.To.Add(_usuario.Email);
                    mail.Subject    = "Correo desde contacto";
                    mail.IsBodyHtml = true;
                    mail.Body       = model.Mensaje;

                    var SmtpServer = new SmtpClient("smtp.live.com"); // or "smtp.gmail.com"
                    SmtpServer.Port                  = 587;
                    SmtpServer.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    SmtpServer.UseDefaultCredentials = false;

                    // Agrega tu correo y tu contraseña, hemos usado el servidor de Outlook.
                    SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Claroa2060");
                    SmtpServer.EnableSsl   = true;
                    SmtpServer.Send(mail);
                }
                catch (Exception e)
                {
                    rm.setResponse(false, e.Message);
                    return(Json(rm));

                    throw;
                }

                rm.setResponse(true);
                rm.function = "CerrarContacto();";
            }

            return(Json(rm));
        }
Пример #2
0
        public JsonResult EnviarCorreo(ContactoViewModel model)
        {
            var rm = new ResponseModel();

            if (ModelState.IsValid)
            {
                try
                {
                    var _usuario = usuario.ObtenerUsuario(FrontOfficeStartUp.UsuarioVisualizando());
                    var mail     = new MailMessage();
                    mail.From = new MailAddress(model.Correo);//Ojo! solo está aceptando correos de outlook
                    mail.To.Add(_usuario.Email);
                    mail.Subject    = "Correo desde Pagina Web";
                    mail.IsBodyHtml = true;
                    mail.Body       = model.Mensaje;

                    var SmtpServer = new SmtpClient("smtp.live.com")
                    {
                        Port                  = 587,
                        DeliveryMethod        = SmtpDeliveryMethod.Network,
                        UseDefaultCredentials = false,
                        Credentials           = new System.Net.NetworkCredential("*****@*****.**", "Contra2014"),
                        EnableSsl             = true
                    }; //or smpt.gmail.com

                    SmtpServer.Send(mail);
                }
                catch (Exception ex)
                {
                    rm.SetResponse(false, ex.Message);
                    return(Json(rm));

                    throw;
                }

                rm.SetResponse(true);
                rm.function = "cerrarContacto();";
            }

            return(Json(rm));
        }
Пример #3
0
        public JsonResult EnviarCorreo(ContactoViewModel model)
        {
            var rm = new ResponseModel();

            if (ModelState.IsValid)
            {
                try
                {
                    var _usuario = usuario.Obtener(FrontOfficeStartUp.UsuarioVisualizando());
                    var mail     = new MailMessage();
                    mail.From = new MailAddress(model.Correo, model.Nombre);
                    mail.To.Add(_usuario.Email);
                    mail.Subject    = "Correo desde contato";
                    mail.IsBodyHtml = true;
                    mail.Body       = model.Mensaje;

                    var smtserver = new SmtpClient("smtp.live.com");
                    smtserver.Port                  = 587;
                    smtserver.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    smtserver.UseDefaultCredentials = false;
                    smtserver.Credentials           = new System.Net.NetworkCredential("", "");
                    smtserver.EnableSsl             = true;
                    smtserver.Send(mail);
                }
                catch (Exception e)
                {
                    rm.SetResponse(false, e.Message);
                    return(Json(rm));

                    throw;
                }
                rm.SetResponse(true);
                rm.function = "CerrarContacto();";
            }
            return(Json(rm));
        }
Пример #4
0
 public ActionResult PDF()
 {
     return(View(
                usuario.Obtener(FrontOfficeStartUp.UsuarioVisualizando(), true)
                ));
 }