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; ...@@ -16,6 +16,7 @@ import org.springframework.stereotype.Controller;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.util.List; import java.util.List;
import java.util.Objects;
@Controller @Controller
@AllArgsConstructor(onConstructor_ = @__({@Autowired})) @AllArgsConstructor(onConstructor_ = @__({@Autowired}))
...@@ -162,9 +163,16 @@ public class AdmissionFormDAOController { ...@@ -162,9 +163,16 @@ public class AdmissionFormDAOController {
ByteArrayInputStream pdfStream = pdfService.convertHtmlToPdf(emailBody); 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( this.emailService.sendHtmlEmail(
data.getFatherEmail(), recipients,
"ADMISSION APPOINTMENT | " + data.getSchool().toUpperCase(), "ADMISSION APPOINTMENT | " + data.getSchool().toUpperCase(),
emailBody, emailBody,
pdfStream pdfStream
......
...@@ -40,4 +40,16 @@ public class EmailService { ...@@ -40,4 +40,16 @@ public class EmailService {
mailSender.send(message); 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