spring mail codings

Solutions on MaxInterview for spring mail codings by the best coders in the world

showing results for - "spring mail codings"
Roberto
03 Jan 2019
1public class EmailService {
2
3	
4
5	@Autowired
6	private JavaMailSender sender;
7
8	@Autowired
9	private Configuration config;
10
11	
12
13	public ICUser sendEmail(ICUser user, Map<String, Object> model) {
14		// User response = new User();
15		MimeMessage message = sender.createMimeMessage();
16		try {
17			// set mediaType
18			MimeMessageHelper helper = new MimeMessageHelper(message, MimeMessageHelper.MULTIPART_MODE_MIXED_RELATED,
19					StandardCharsets.UTF_8.name());
20			// add attachment
21	//		 helper.addAttachment("logo.jpg", new ClassPathResource("logo.jpg"));
22
23			Template t = config.getTemplate("email-template.ftl");
24			String html = FreeMarkerTemplateUtils.processTemplateIntoString(t, model);
25
26			helper.setTo(user.getEmail());
27			helper.setText(html, true);
28			helper.setSubject("OnClick Info Team");
29			helper.setFrom("syedazar016@gmail.com");
30			sender.send(message);
31}
32}
similar questions
queries leading to this page
spring mail codings