Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
Update notification email content (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdrGuyson authored Aug 10, 2021
1 parent d86795e commit f21bdf9
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public EmailService(EmailUtil emailUtil) {
this.emailUtil = emailUtil;
}

public Email sendEmail(String emailAddress, String subject, String message) throws IOException, MessagingException {
public Email sendEmail(String emailAddress, String subject, String message, boolean showButton) throws IOException, MessagingException {
Email email = new Email();
email.setEmail(emailAddress);
email.setSubject(subject);
Expand All @@ -27,6 +27,7 @@ public Email sendEmail(String emailAddress, String subject, String message) thro
model.put("emailAddress", emailAddress);
model.put("subject", subject);
model.put("message", message);
model.put("showButton", showButton);
email.setProps(model);

emailUtil.sendSimpleMessage(email);
Expand Down
65 changes: 58 additions & 7 deletions src/main/java/org/sefglobal/scholarx/util/ProgramUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sefglobal.scholarx.util;

import org.apache.commons.lang.StringUtils;
import org.sefglobal.scholarx.model.Mentee;
import org.sefglobal.scholarx.model.Mentor;
import org.sefglobal.scholarx.model.Program;
Expand Down Expand Up @@ -30,35 +31,85 @@ public void sendMenteeApplicationEmails(long id, Optional<Program> program) thro

String message;
for (Mentor mentor : mentors) {
message = "You have been " + mentor.getState().name().toLowerCase();
emailService.sendEmail(mentor.getProfile().getEmail(), program.get().getTitle(), message);

if (mentor.getState().name().equals("APPROVED")) {

message = "Dear " + mentor.getProfile().getFirstName() + ",<br /><br />" +
"<b>Congratulations!</b><br />You have been selected by the " +
"ScholarX committee to be a mentor of the " + program.get().getTitle() +
" program. We will soon open up the program for students to " +
"apply and keep you posted on the progress via email. Until " +
"then, read more about student experience " +
"<a href=\"https://medium.com/search?q=scholarx\">here</a> and reach out to us via " +
"<a href=\"mailto:[email protected]\">[email protected]</a> " +
"for any clarifications.";

emailService.sendEmail(mentor.getProfile().getEmail(), StringUtils.capitalize(mentor.getState().name()), message, false);

} else if (mentor.getState().name().equals("REJECTED")) {

message = "Dear " + mentor.getProfile().getFirstName() + ",<br /><br />" +
"Thank you very much for taking your time to apply for the " + program.get().getTitle() + " program. " +
"However, due to the competitive nature of the mentor applications, your application " +
"did not make it to the final list of mentors for the program. We encourage you to try " +
"again next year and follow us on our social media channels for future programs. " +
"If you have any clarifications, please reach out to us via " +
"<a href=\"mailto:[email protected]\">[email protected]</a>";

emailService.sendEmail(mentor.getProfile().getEmail(), StringUtils.capitalize(mentor.getState().name()), message, false);

}
}
}

public void sendMenteeSelectionEmails(long id, Optional<Program> program) throws IOException, MessagingException {
List<Mentor> approvedMentors = mentorRepository.findAllByProgramIdAndState(id, EnrolmentState.APPROVED);
List<Mentee> mentees = menteeRepository.findAllByProgramId(id);

String message = "You can approve or reject your mentees by visiting the dashboard";
// Notify mentors
for (Mentor mentor : approvedMentors) {
emailService.sendEmail(mentor.getProfile().getEmail(), program.get().getTitle(), message);

String message = "Dear " + mentor.getProfile().getFirstName() + ",<br /><br />" +
"You have student applications waiting to be reviewed. You can approve or reject your mentees " +
"by visiting the <b>ScholarX dashboard.</b>";

emailService.sendEmail(mentor.getProfile().getEmail(), program.get().getTitle(), message, true);
}

// Notify mentees
for (Mentee mentee : mentees) {
String message = "Dear " + mentee.getProfile().getFirstName() + ",<br /><br />" +
"Thank you very much for applying to the " + program.get().getTitle() + " program. Your application has been received. " +
"Mentors will soon review your applications and we will keep you posted on the progress via email. " +
"Until then, read more about student experience <a href=\"https://medium.com/search?q=scholarx\">here</a> and reach out to us via " +
"<a href=\"mailto:[email protected]\">[email protected]</a> " +
"for any clarifications.";

emailService.sendEmail(mentee.getProfile().getEmail(), program.get().getTitle(), message, false);
}
}

public void sendOnGoingEmails(long id, Optional<Program> program) throws IOException, MessagingException {
List<Mentor> approvedMentors = mentorRepository.findAllByProgramIdAndState(id, EnrolmentState.APPROVED);

String message = "You can check your mentees by visiting the dashboard";
for (Mentor mentor : approvedMentors) {
emailService.sendEmail(mentor.getProfile().getEmail(), program.get().getTitle(), message);

String message = "Dear " + mentor.getProfile().getFirstName() + ",<br /><br />" +
"<b>Congratulations!</b><br />Students have accepted you as their mentor. " +
"You can check your mentees and their contact details by visiting the <b>ScholarX dashboard.</b> " +
"Please make the first contact with them as we have instructed them to wait for your email.";

emailService.sendEmail(mentor.getProfile().getEmail(), program.get().getTitle(), message, true);
}
}

public void sendMentorConfirmationEmails(long id, Optional<Program> program) throws IOException, MessagingException {
List<Mentee> mentees = menteeRepository.findAllByProgramId(id);

String message = "You can check your mentor by visiting the dashboard";

for (Mentee mentee : mentees) {
emailService.sendEmail(mentee.getProfile().getEmail(), program.get().getTitle(), message);
emailService.sendEmail(mentee.getProfile().getEmail(), program.get().getTitle(), message, true);
}
}
}
169 changes: 142 additions & 27 deletions src/main/resources/templates/scholarx.html
Original file line number Diff line number Diff line change
@@ -1,68 +1,181 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>ScholarX email template</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'/>
<link href="http://fonts.googleapis.com/css?family=Roboto" rel="stylesheet" type="text/css"/>

<style>
body {
font-family: 'Roboto', sans-serif;
font-family: "Roboto", sans-serif;
font-size: 48px;
}
table, td, div, h1, p {

table,
td,
div,
h1,
p {
font-family: Arial, sans-serif;
}

@media screen and (max-width: 530px) {
.col-lge {
max-width: 100% !important;
}
}

@media screen and (min-width: 531px) {
.col-sml {
max-width: 27% !important;
}

.col-lge {
max-width: 73% !important;
}
}
</style>
</head>
<body style="margin:0;padding:0;word-spacing:normal;background-color:#ffffff;">
<div role="article" aria-roledescription="email" lang="en" style="text-size-adjust:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;background-color:#ffffff;">
<table role="presentation" style="width:100%;border:none;border-spacing:0;">

<body style="
margin: 0;
padding: 0;
word-spacing: normal;
background-color: #ffffff;
">
<div role="article" aria-roledescription="email" lang="en" style="
text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
background-color: #ffffff;
">
<table role="presentation" style="width: 100%; border: none; border-spacing: 0">
<tr>
<td align="center" style="padding:0;">
<table role="presentation" style="width:94%;max-width:600px;border:none;border-spacing:0;text-align:left;font-family:Arial,sans-serif;font-size:16px;line-height:22px;color:#363636;">
<td align="center" style="padding: 0">
<table role="presentation" style="
width: 94%;
max-width: 600px;
border: none;
border-spacing: 0;
text-align: left;
font-family: Arial, sans-serif;
font-size: 16px;
line-height: 22px;
color: #363636;
">
<tr>
<td style="padding:40px 30px 30px 30px;text-align:center;font-size:24px;font-weight:bold;">
<a href="https://sefglobal.org/" style="text-decoration:none;"><img src="https://sefglobal.org/assets/img/brand/logo.png" width="165" style="width:80%;max-width:165px;height:auto;border:none;text-decoration:none;color:#ffffff;"></a>
<td style="
padding: 40px 30px 30px 30px;
text-align: center;
font-size: 24px;
font-weight: bold;
">
<a href="https://sefglobal.org/" style="text-decoration: none"><img
src="https://sefglobal.org/assets/img/brand/logo.png" width="165" style="
width: 80%;
max-width: 165px;
height: auto;
border: none;
text-decoration: none;
color: #ffffff;
"/></a>
</td>
</tr>
<tr>
<td style="padding:35px 30px 11px 30px;font-size:0;background-color:#ffffff;border-bottom:1px solid #f0f0f5;border-color:rgba(201,201,207,.35);">
<td style="
padding: 35px 30px 11px 30px;
font-size: 0;
background-color: #ffffff;
border-bottom: 1px solid #f0f0f5;
border-color: rgba(201, 201, 207, 0.35);
">
<div class="col-lge" style="
display: inline-block;
width: 100%;
min-width: 100%;
vertical-align: top;
padding-bottom: 20px;
font-family: Arial, sans-serif;
font-size: 16px;
line-height: 22px;
color: #363636;
">
<p style="margin-top: 0; margin-bottom: 22px" th:utext="${message}">

<div class="col-sml" style="display:inline-block;width:100%;max-width:145px;vertical-align:top;text-align:left;font-family:Arial,sans-serif;font-size:14px;color:#363636;">
<img src="https://assets.codepen.io/210284/icon.png" width="115" style="width:80%;max-width:115px;margin-bottom:20px;">
</div>

<div class="col-lge" style="display:inline-block;width:100%;max-width:395px;vertical-align:top;padding-bottom:20px;font-family:Arial,sans-serif;font-size:16px;line-height:22px;color:#363636;">
<p th:text="${message}" style="margin-top:0;margin-bottom:18px;"></p>
<p style="margin:0;"><a href="http://sef-scholarx.herokuapp.com/home" style="background: #ff3884; text-decoration: none; padding: 10px 25px; color: #ffffff; border-radius: 4px; display:inline-block; mso-padding-alt:0;text-underline-color:#ff3884">
<span style="mso-text-raise:10pt;font-weight:bold;">View Dashboard</span>
</a></p>
</p>
<p style="margin-top: 0; margin-bottom: 18px">
Best regards,<br/>
Dharana Jayawardane,<br/>
Program Manager, <br/>
ScholarX,<br/>
Sustainable Education Foundation
</p>
<p style="margin: 0" th:if="${showButton}">
<a href="http://sef-scholarx.herokuapp.com/home" style="
background: #1890ff;
text-decoration: none;
padding: 10px 25px;
color: #ffffff;
border-radius: 4px;
display: inline-block;
mso-padding-alt: 0;
text-underline-color: #1890ff;
">
<span style="mso-text-raise: 10pt; font-weight: bold">View Dashboard</span>
</a>
</p>
</div>
</td>
</tr>
<tr>
<td style="padding:30px;text-align:center;font-size:12px;background-color:#404040;color:#cccccc;">
<p style="margin:0 0 8px 0;">
<a href="https://www.facebook.com/sustainableeducationfoundation" style="text-decoration:none;"><img src="https://assets.codepen.io/210284/facebook_1.png" width="40" height="40" alt="f" style="display:inline-block;color:#cccccc;"></a>
<a href="https://twitter.com/goasksef" style="text-decoration:none;"><img src="https://assets.codepen.io/210284/twitter_1.png" width="40" height="40" alt="t" style="display:inline-block;color:#cccccc;"></a>
<td style="
padding: 30px;
text-align: center;
font-size: 12px;
background-color: #f0f2f5;
color: #cccccc;
">
<p style="margin: 0 0 8px 0">
<a href="https://www.facebook.com/sustainableeducationfoundation"
style="text-decoration: none">
<img
src="https://img.icons8.com/material-outlined/192/000000/facebook-f.png"
alt="facebook-icon"
height="40"
width="40"
style="display: inline-block; opacity: 0.35;">
</a>
<a href="https://twitter.com/goasksef" style="text-decoration: none">
<img
src="https://img.icons8.com/ios-filled/150/000000/twitter.png"
alt="facebook-icon"
height="35"
width="35"
style="display: inline-block; opacity: 0.35;">
</a>
<a href="https://www.linkedin.com/company/sefglobal/" style="text-decoration: none">
<img
src="https://img.icons8.com/windows/128/000000/linkedin-2.png"
alt="facebook-icon"
height="40"
width="40"
style="display: inline-block; opacity: 0.35;">
</a>
<a href="https://www.instagram.com/sefglobal/" style="text-decoration: none">
<img
src="https://img.icons8.com/material-outlined/192/000000/instagram-new--v1.png"
alt="facebook-icon"
height="40"
width="40"
style="display: inline-block; opacity: 0.35;">
</a>
</p>
<p style="margin: 0; font-size: 14px; line-height: 20px">
&copy; Sustainable Education Foundation - SEF 2021
</p>
<p style="margin:0;font-size:14px;line-height:20px;">&copy; Sustainable Education Foundation - SEF 2021</p>
</td>
</tr>
</table>
Expand All @@ -71,4 +184,6 @@
</table>
</div>
</body>

</html>

0 comments on commit f21bdf9

Please sign in to comment.