@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();
		
			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(); 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; }