// // GET: /ParamCorreo/Details/5 public ViewResult Details(string id) { string idDecrypted = MiUtil.desEncriptar(HttpUtility.UrlDecode(id)); int intId = Convert.ToInt32(idDecrypted); paramcorreo paramcorreo = db.paramcorreo.Find(intId); return(View(paramcorreo)); }
public ActionResult DeleteConfirmed(int id) { paramcorreo paramcorreo = db.paramcorreo.Find(id); db.paramcorreo.Remove(paramcorreo); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult EnviarCorreoFromAWS(string abonoId, int abonoNro) { string idDecrypted = abonoId; //MiUtil.desEncriptar(abonoId); int intId = Convert.ToInt32(idDecrypted); ViewBag.abonoId = intId; ImpresionAbono ia = impresionAbono(intId); if (ia != null) { crearArchivo(intId, abonoNro); string file = nombreArchivo(intId, abonoNro); ViewBag.abonoId = abonoId; paramcorreo paramcorreo = (paramcorreo)db.paramcorreo.FirstOrDefault(em => em.EmpresaId == 1); if (paramcorreo != null) { // paramcorreos.ToList().Where(em => em.EmpresaId == empresaId); //db.ParamCorreos.Find(empresaId); empresa empresa = (empresa)db.empresa.Find(ia.EmpresaId); EnviarCorreo enviarcorreo = new EnviarCorreo() { Empresa = empresa.Nombre, Servidor = paramcorreo.Servidor, Puerto = paramcorreo.Puerto, Usuario = paramcorreo.Usuario, Password = paramcorreo.Password, Destinatario = ia.EmailCliente, Asunto = "Comprobante de Abono", Mensaje = "Adjunto encontrara el comprobante de abono", Adjunto = file }; return(View("EnviarCorreo", enviarcorreo)); } else { ViewBag.Layout = 0; ViewBag.action = "index"; ViewBag.controller = "Home"; ViewBag.tipo = "bg-warning"; ViewBag.mensaje = "Debe definir los parametros de correo para poder enviar correos"; return(View("../Shared/Mensaje")); } } else { ViewBag.Layout = 0; ViewBag.action = "index"; ViewBag.controller = "Home"; ViewBag.tipo = "bg-warning"; ViewBag.mensaje = "No es posible enviar comprobantes de abonos inactivos"; return(View("../Shared/Mensaje")); } }
public ActionResult Edit(paramcorreo paramcorreo) { if (ModelState.IsValid) { db.Entry(paramcorreo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } var e = db.empresa.Where(u => u.Estado == true); int empresaId = Convert.ToInt32(Session["EmpresaId"]); ViewBag.EmpresaId = new SelectList(e.Where(u => u.EmpresaId == empresaId), "EmpresaId", "Nombre", empresaId); //ViewBag.EmpresaId = new SelectList(db.Empresas, "EmpresaId", "Nombre", paramcorreo.EmpresaId); return(View(paramcorreo)); }
// // GET: /ParamCorreo/Edit/5 public ActionResult Edit(string id) { //int empresaId = 0; //if (Session["EmpresaId"] != null) // Int32.TryParse(Session["EmpresaId"].ToString(), out empresaId); string idDecrypted = MiUtil.desEncriptar(HttpUtility.UrlDecode(id)); int intId = Convert.ToInt32(idDecrypted); paramcorreo paramcorreo = db.paramcorreo.Find(intId); var e = db.empresa.Where(u => u.Estado == true); // int empresaId = Convert.ToInt32(Session["EmpresaId"]); // ViewBag.EmpresaId = new SelectList(e.Where(u => u.EmpresaId == empresaId), "EmpresaId", "Nombre", empresaId); //ViewBag.EmpresaId = new SelectList(db.Empresas, "EmpresaId", "Nombre", paramcorreo.EmpresaId); return(View(paramcorreo)); }
public ActionResult Create(paramcorreo paramcorreo) { int empresaId = 0; if (Session["EmpresaId"] != null) { Int32.TryParse(Session["EmpresaId"].ToString(), out empresaId); } paramcorreo.EmpresaId = empresaId; if (ModelState.IsValid) { db.paramcorreo.Add(paramcorreo); db.SaveChanges(); return(RedirectToAction("Index")); } var e = db.empresa.Where(u => u.Estado == true); // int empresaId = Convert.ToInt32(Session["EmpresaId"]); ViewBag.EmpresaId = new SelectList(e.Where(u => u.EmpresaId == empresaId), "EmpresaId", "Nombre", empresaId); //ViewBag.EmpresaId = new SelectList(db.Empresas, "EmpresaId", "Nombre", paramcorreo.EmpresaId); return(View(paramcorreo)); }
// // GET: /ParamCorreo/Delete/5 public ActionResult Delete(int id) { paramcorreo paramcorreo = db.paramcorreo.Find(id); return(View(paramcorreo)); }
public static bool enviarFromAWS(int empresaRemitente, string email, string asunto, string mensaje) { CrediAdminContext db = new CrediAdminContext(); paramcorreo paramcorreo = (paramcorreo)db.paramcorreo.FirstOrDefault(em => em.EmpresaId == empresaRemitente); if (paramcorreo != null) { empresa empresa = (empresa)db.empresa.Find(empresaRemitente); EnviarCorreo enviarcorreo = new EnviarCorreo() { Empresa = empresa.Nombre, Servidor = paramcorreo.Servidor, Puerto = paramcorreo.Puerto, Usuario = paramcorreo.Usuario, Password = paramcorreo.Password, Destinatario = email, Asunto = asunto, //Nombre.ToUpper()+" Bienvenido a CrediAdmin", Mensaje = mensaje, //"<p>Ya puede ingresar a nuestra plataforma para administrar sus creditos.</p> <p>Nombre de Usuario:" + EmpEmail + "</p><p>Contraseña:" + clave + "</p>", Adjunto = "" }; var fromAddress = new MailAddress(enviarcorreo.Usuario, enviarcorreo.Empresa); var toAddress = new MailAddress(enviarcorreo.Destinatario, ""); string fromPassword = enviarcorreo.Password; string subject = enviarcorreo.Asunto; string body = enviarcorreo.Mensaje; String FROM = enviarcorreo.Usuario; // "*****@*****.**"; // Replace with your "From" address. This address must be verified. String TO = email; //"*****@*****.**"; // Replace with a "To" address. If your account is still in the // sandbox, this address must be verified. String SUBJECT = asunto; //"Amazon SES test (SMTP interface accessed using C#)"; String BODY = mensaje; //"This email was sent through the Amazon SES SMTP interface by using C#."; // Supply your SMTP credentials below. Note that your SMTP credentials are different from your AWS credentials. String SMTP_USERNAME = ConfigurationManager.AppSettings["AWSAccessKey"].ToString(); // "AKIAIZOJPFIFCACIJ53A"; // Replace with your SMTP username. String SMTP_PASSWORD = ConfigurationManager.AppSettings["AWSSecretKey"].ToString(); // "Au9jMcd8Z07RmDNYgEvxs9f+3rpf46RruJ+1LgGEbzr5"; // Replace with your SMTP password. // Amazon SES SMTP host name. This example uses the US West (Oregon) region. String HOST = ConfigurationManager.AppSettings["AWSServer"].ToString(); // Port we will connect to on the Amazon SES SMTP endpoint. We are choosing port 587 because we will use // STARTTLS to encrypt the connection. const int PORT = 587; MailMessage message = new MailMessage(fromAddress, toAddress); message.Subject = subject; message.Body = body; message.IsBodyHtml = true; System.Net.Mail.Attachment attachment = null; if (!String.IsNullOrEmpty(enviarcorreo.Adjunto)) { attachment = new System.Net.Mail.Attachment(enviarcorreo.Adjunto); } // Create an SMTP client with the specified host name and port. using (System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(HOST, PORT)) { // Create a network credential with your SMTP user name and password. client.Credentials = new System.Net.NetworkCredential(SMTP_USERNAME, SMTP_PASSWORD); // Use SSL when accessing Amazon SES. The SMTP session will begin on an unencrypted connection, and then // the client will issue a STARTTLS command to upgrade to an encrypted connection using SSL. client.EnableSsl = true; // Send the email. try { // Console.WriteLine("Attempting to send an email through the Amazon SES SMTP interface..."); //client.Send(FROM, TO, SUBJECT, BODY); client.Send(message); //Console.WriteLine("Email sent!"); return(true); } catch (Exception ex) { Console.WriteLine("The email was not sent."); Console.WriteLine("Error message: " + ex.Message); } } } return(false); }
public static bool enviarCorreo(int empresaRemitente, string email, string asunto, string mensaje) { CrediAdminContext db = new CrediAdminContext(); paramcorreo paramcorreo = (paramcorreo)db.paramcorreo.FirstOrDefault(em => em.EmpresaId == empresaRemitente); if (paramcorreo != null) { empresa empresa = (empresa)db.empresa.Find(empresaRemitente); EnviarCorreo enviarcorreo = new EnviarCorreo() { Empresa = empresa.Nombre, Servidor = paramcorreo.Servidor, Puerto = paramcorreo.Puerto, Usuario = paramcorreo.Usuario, Password = paramcorreo.Password, Destinatario = email, Asunto = asunto, //Nombre.ToUpper()+" Bienvenido a CrediAdmin", Mensaje = mensaje, //"<p>Ya puede ingresar a nuestra plataforma para administrar sus creditos.</p> <p>Nombre de Usuario:" + EmpEmail + "</p><p>Contraseña:" + clave + "</p>", Adjunto = "" }; var fromAddress = new MailAddress(enviarcorreo.Usuario, enviarcorreo.Empresa); var toAddress = new MailAddress(enviarcorreo.Destinatario, ""); string fromPassword = enviarcorreo.Password; string subject = enviarcorreo.Asunto; string body = enviarcorreo.Mensaje; System.Net.Mail.Attachment attachment = null; if (!String.IsNullOrEmpty(enviarcorreo.Adjunto)) { attachment = new System.Net.Mail.Attachment(enviarcorreo.Adjunto); } var smtp = new SmtpClient { Host = enviarcorreo.Servidor, Port = enviarcorreo.Puerto, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, // UseDefaultCredentials = true, UseDefaultCredentials = false, Credentials = new System.Net.NetworkCredential(fromAddress.Address, fromPassword) }; MailMessage message = new MailMessage(fromAddress, toAddress); message.Subject = subject; message.Body = body; message.IsBodyHtml = true; if (attachment != null) { message.Attachments.Add(attachment); } try { smtp.Send(message); //Response.Redirect(urlPapa, true); return(true); } catch (Exception ex) { //ViewBag.mensaje = "Exception caught in CreateTestMessage2(): {0}" + ex.ToString(); Console.WriteLine("Exception caught in CreateTestMessage2(): {0}", ex.ToString()); } } return(false); }