Commit dfc70628 by Jose Baez

Merge branch 'sendemail3' into 'develop'

Sendemail3

See merge request !43
parents e5804c67 5ba34b13
......@@ -27,7 +27,7 @@ public class Filtros extends HttpServlet {
String nombre_postulante = req.getParameter("nombre");
String apellido_postulante = req.getParameter("apellido");
String correo_postulante = req.getParameter("correo");
int bootcamp_id = Integer.parseInt(req.getParameter("bootcamp_id"));
String bootcamp_idStr = req.getParameter("bootcampId"); // Este es el dato
String nombre = req.getParameter("nombreBuscar")== null ? "0" : req.getParameter("nombreBuscar");
if(respuesta != null) {
System.out.println(valor);
......@@ -37,13 +37,9 @@ public class Filtros extends HttpServlet {
if (valor.equals("1")) {
try {
SendMail send = new SendMail();
send.sendingMail(correo_postulante, nombre_postulante, apellido_postulante, bootcamp_id);
// Averiguar que recibo con el SOUT sobretodo en bootcamp_id, una vez que pueda tener el
// login.
// Para obtener el login necesito poder iniciar sesion en Usuario
// Una vez iniciado sesion se prueba cambiando el estado de 'RECHAZADO' a 'Aceptado'
System.out.println(correo_postulante+nombre_postulante+apellido_postulante+ bootcamp_id);
send.sendingMail(correo_postulante, nombre_postulante, apellido_postulante, bootcamp_idStr);
} catch (MessagingException e) {
resp.sendRedirect("postulante-consulta.jsp");
throw new RuntimeException(e);
}
}
......
......@@ -4,19 +4,13 @@ import com.roshka.proyectofinal.bootcamp.BootcampDao;
import com.roshka.proyectofinal.entity.Bootcamp;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.swing.*;
public class SendMail {
......@@ -25,12 +19,10 @@ public class SendMail {
}
public void sendingMail(String postulanteCorreoDestino, String nombre, String apellido, int bootcampId) throws AddressException, MessagingException {
// emanuel.lugo01@gmail.com
public void sendingMail(String postulanteCorreoDestino, String nombre, String apellido, String bootcampId) throws AddressException, MessagingException {
int bootId = Integer.parseInt(bootcampId);
BootcampDao bootcampDao = new BootcampDao();
Bootcamp bootcamp = bootcampDao.getBootcampById(bootcampId);
Bootcamp bootcamp = bootcampDao.getBootcampById(bootId);
String correo = "nahuelmereles1@gmail.com";
String contra = "ozydnpynyoqsowjn";
......@@ -46,13 +38,12 @@ public class SendMail {
MimeMessage mensaje = new MimeMessage(s);
mensaje.setFrom(new InternetAddress(correo));
mensaje.addRecipient(Message.RecipientType.TO, new InternetAddress(correoDestino));
mensaje.setSubject("Confirmacion al Bootcamp de " + bootcamp.getTitulo()); // Asunto del correo
mensaje.setText("Hola " + nombre + " " + apellido + ", fuiste aceptado al bootcamp de " + bootcamp.getTitulo() + " que empezara el " + bootcamp.getFecha_inicio() + " y terminara el " + bootcamp.getFecha_fin() + ", muchas felicidades y esperamos verte pronto."); // Mensaje del correo
mensaje.setSubject("Confirmacion al " + bootcamp.getTitulo()); // Asunto del correo
mensaje.setText("Hola " + nombre + " " + apellido + ", fuiste aceptado al " + bootcamp.getTitulo() + " que empezara el " + bootcamp.getFecha_inicio() + " y terminara el " + bootcamp.getFecha_fin() + ", muchas felicidades y esperamos verte pronto."); // Mensaje del correo
Transport transport = s.getTransport("smtp");
transport.connect(correo, contra);
transport.sendMessage(mensaje,mensaje.getAllRecipients());
transport.close();
JOptionPane.showMessageDialog(null, "Mensaje enviado");
}
}
......@@ -24,6 +24,10 @@
</head>
<body>
<div class="botones"><a href="logout">LOGOUT</a><br>
<a href="index.html">INICIO</a><br>
<a href="menu.jsp">MENU</a><br>
</div>
<div class="logo">
<a href="./index.html"> <img class="logoi" src="imagenes/logo-roshka.svg" alt="" /> </a>
<!-- logo con link -->
......@@ -136,10 +140,10 @@
<form action="filtros-postulante" method="get">
<input type="hidden" name="valor" value="1">
<input type="hidden" name="id" value="${postulante.id}">
<input type="hidden" name="bootcampId" value="${postulante.bootcampId}">
<input type="hidden" name="nombre" value="${postulante.nombre}">
<input type="hidden" name="apellido" value="${postulante.apellido}">
<input type="hidden" name="correo" value="${postulante.correo}">
<input type="hidden" name="bootcamp_id" value="${postulante.bootcamp_id}">
<button type="submit">Aceptado</button>
</form>
</c:otherwise>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment