/**
         * Metodo para compartir el anuncio a traves del email
         * 
         * @param email
         * @param model
         * @param authentication
         * @param req
         * @param flash
         * @return
         */
@RequestMapping(value = "/shareAnuncio", method = RequestMethod.POST)
	public String shareAnuncio(@RequestParam("email") String email, Model model, Authentication authentication,
			HttpServletRequest req, RedirectAttributes flash) {
		logger.info("contactar-anunciante");
		Integer id = Integer.parseInt(req.getParameter("id"));
		try {
			Vehiculo veh = vehiculoService.findById(id);
			String appUrl = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort();
			// Email message
			SimpleMailMessage shareEmail = new SimpleMailMessage();
			shareEmail.setTo(email);
			shareEmail.setSubject("Coches: Un amigo te recomienda este anuncio");
			shareEmail.setText("¡Hola!\n" + "Un amigo se ha acordado de ti al ver este anuncio " + veh.getMarca()
					+ " y cree que te puede interesar." + "\n¿Tienes curiosidad?\n" + appUrl + "/anuncio/detalle/"
					+ id);
			emailService.sendEmail(shareEmail);
			model.addAttribute("emailSend", "El correo se envio correctamente");
			logger.info("Email enviado correctamente");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "redirect:/anuncio/detalle/" + id;
	}
@RequestMapping(value = "/shareAnuncio", method = RequestMethod.POST)
public String shareAnuncio(@RequestParam("email") String email, Model model, Authentication authentication,
HttpServletRequest req, RedirectAttributes flash) {
logger.info("contactar-anunciante");
Integer id = Integer.parseInt(req.getParameter("id"));
try {
Vehiculo veh = vehiculoService.findById(id);
String appUrl = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort();
// Email message
SimpleMailMessage shareEmail = new SimpleMailMessage();
shareEmail.setTo(email);
shareEmail.setSubject("Coches: Un amigo te recomienda este anuncio");
shareEmail.setText("¡Hola!\n" + "Un amigo se ha acordado de ti al ver este anuncio " + veh.getMarca()
+ " y cree que te puede interesar." + "\n¿Tienes curiosidad?\n" + appUrl + "/anuncio/detalle/"
+ id);
emailService.sendEmail(shareEmail);
model.addAttribute("emailSend", "El correo se envio correctamente");
logger.info("Email enviado correctamente");
} catch (Exception e) {
e.printStackTrace();
}
return "redirect:/anuncio/detalle/" + id;
}
@RequestMapping(value = "/shareAnuncio", method = RequestMethod.POST)
public String shareAnuncio(@RequestParam("email") String email, Model model, Authentication authentication,
HttpServletRequest req, RedirectAttributes flash) {
logger.info("contactar-anunciante");
Integer id = Integer.parseInt(req.getParameter("id"));
try {
Vehiculo veh = vehiculoService.findById(id);
String appUrl = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort();
// Email message
SimpleMailMessage shareEmail = new SimpleMailMessage();
shareEmail.setTo(email);
shareEmail.setSubject("Coches: Un amigo te recomienda este anuncio");
shareEmail.setText("¡Hola!\n" + "Un amigo se ha acordado de ti al ver este anuncio " + veh.getMarca()
+ " y cree que te puede interesar." + "\n¿Tienes curiosidad?\n" + appUrl + "/anuncio/detalle/"
+ id);
emailService.sendEmail(shareEmail);
model.addAttribute("emailSend", "El correo se envio correctamente");
logger.info("Email enviado correctamente");
} catch (Exception e) {
e.printStackTrace();
}
return "redirect:/anuncio/detalle/" + id;
}
@RequestMapping(value = "/shareAnuncio", method = RequestMethod.POST)
public String shareAnuncio(@RequestParam("email") String email, Model model, Authentication authentication,
HttpServletRequest req, RedirectAttributes flash) {
logger.info("contactar-anunciante");
Integer id = Integer.parseInt(req.getParameter("id"));
try {
Vehiculo veh = vehiculoService.findById(id);
String appUrl = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort();
// Email message
SimpleMailMessage shareEmail = new SimpleMailMessage();
shareEmail.setTo(email);
shareEmail.setSubject("Coches: Un amigo te recomienda este anuncio");
shareEmail.setText("¡Hola!\n" + "Un amigo se ha acordado de ti al ver este anuncio " + veh.getMarca()
+ " y cree que te puede interesar." + "\n¿Tienes curiosidad?\n" + appUrl + "/anuncio/detalle/"
+ id);
emailService.sendEmail(shareEmail);
model.addAttribute("emailSend", "El correo se envio correctamente");
logger.info("Email enviado correctamente");
} catch (Exception e) {
e.printStackTrace();
}
return "redirect:/anuncio/detalle/" + id;
}