Last active
August 29, 2015 14:19
-
-
Save robertacosta/8f98ba70f16afaf97bdc to your computer and use it in GitHub Desktop.
Developer Example of sending an email with SendGrid ASM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void sendPatientAssignment(Principle user, String patientName, String patientRoom) { | |
Logger logger = LoggerFactory.getLogger(AdminController.class); | |
SendGrid sendgrid = new SendGrid(System.getenv("SENDGRID_API_KEY")); | |
SendGrid.Email email = new SendGrid.Email(); | |
email.addTo(user.getEmail()); | |
email.setFrom(System.getenv("SENDGRID_FROM_EMAIL")); | |
email.setSubject("Attemper EMR. You have a new patient assignment."); | |
email.setHtml(user.getFirstName()); | |
email.setASMGroupId(124); | |
email.getSMTPAPI().addFilter("templates", "enable", 1); | |
email.getSMTPAPI().addFilter("templates", "template_id", "e95d8718-383c-4741-9ebe-34d083b1cc10"); | |
email.getSMTPAPI().addSubstitution("-name-", patientName); | |
email.getSMTPAPI().addSubstitution("-room-", patientRoom); | |
try { | |
sendgrid.send(email); | |
} catch (SendGridException e) { | |
logger.error("Failed to email user patient assignment: " + e.getMessage()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment