Commit 4e0d6c3a authored by Deep Dey's avatar Deep Dey

feat: add principal email on admission interview email

parent 8b581342
......@@ -16,6 +16,7 @@ import org.springframework.stereotype.Controller;
import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.Objects;
@Controller
@AllArgsConstructor(onConstructor_ = @__({@Autowired}))
......@@ -162,9 +163,16 @@ public class AdmissionFormDAOController {
ByteArrayInputStream pdfStream = pdfService.convertHtmlToPdf(emailBody);
// TODO: also add the principal email here
String principalEmail = "secretariat_lmb@lamartiniere.co";
if (!Objects.equals(data.getSchool(), "La Martiniere for Boys")) {
principalEmail = "lmgkolkata@gmail.com";
}
String[] recipients = {data.getFatherEmail(), principalEmail};
this.emailService.sendHtmlEmail(
data.getFatherEmail(),
recipients,
"ADMISSION APPOINTMENT | " + data.getSchool().toUpperCase(),
emailBody,
pdfStream
......
......@@ -40,4 +40,16 @@ public class EmailService {
mailSender.send(message);
}
public void sendHtmlEmail(String[] to, String subject, String htmlBody, ByteArrayInputStream attachment) throws MessagingException, IOException {
MimeMessage message = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setSubject(subject);
helper.setTo(to);
helper.setText(htmlBody, true); // true indicates HTML
ByteArrayDataSource dataSource = new ByteArrayDataSource(attachment, "application/pdf");
helper.addAttachment("interaction.pdf", dataSource);
mailSender.send(message);
}
}
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