Class MailUtil
java.lang.Object
com.ssgllc.fish.service.util.published.MailUtil
Utility class for sending emails, including support for HTML content, and attachments.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidsendEmail(String to, String subject, String htmlContent, com.ssgllc.fish.document.GeneratedDoc attachment, String messageId, String interfaceMessageId) Sends an HTML email with a singleGeneratedDocattachment to the specified recipient.
Internally delegates to the method that handles multiple attachments.static voidsendEmail(String to, String cc, String bcc, String subject, String htmlContent, List<com.ssgllc.fish.document.GeneratedDoc> attachments, String messageId, String interfaceMessageId) Sends an HTML email with optional CC, BCC, and multipleGeneratedDocattachments to the specified recipient.
If the list of attachments is empty or null, the email is sent without attachments.
An InterfaceLog record will be created for auditing and tracking only if bothmessageIdandinterfaceMessageIdhave values.static voidsendEmail(String to, String cc, String bcc, String subject, Map<String, Object> contextEntries, String templateName, List<com.ssgllc.fish.document.GeneratedDoc> attachments, String messageId, String interfaceMessageId) Sends an HTML email by rendering a named template with the provided context variables, and optionally includes CC, BCC, and attachments.
If the template content cannot be resolved, the method logs an error and does not send the email.
An InterfaceLog record will be created for auditing and tracking only if bothmessageIdandinterfaceMessageIdhave values.static voidsendEmail(String to, String subject, String htmlContent, List<com.ssgllc.fish.document.GeneratedDoc> attachments, String messageId, String interfaceMessageId) Sends an HTML email with optional attachments from GeneratedDoc holding document data in memory to the specified recipient.
If a single attachment is provided, it delegates to the multi-attachment method.
If the list of attachments is empty or null, the email is sent without attachments.
-
Constructor Details
-
MailUtil
public MailUtil(com.ssgllc.fish.service.MailService mailService)
-
-
Method Details
-
sendEmail
public static void sendEmail(String to, String subject, String htmlContent, com.ssgllc.fish.document.GeneratedDoc attachment, String messageId, String interfaceMessageId) Sends an HTML email with a singleGeneratedDocattachment to the specified recipient.
Internally delegates to the method that handles multiple attachments.- Parameters:
to- The recipient's email address.subject- The subject line of the email.htmlContent- The body content of the email in HTML format.attachment- AGeneratedDocobject to be attached to the email.messageId- An identifier for the message, need not be uniqueinterfaceMessageId- An identifier for the interface where this email is sent from. An InterfaceLog record will be created for auditing and tracking, only if messageId and interfaceMessageId has values.
Groovy example:
def doc = bpmUtil.generateDocxDocumentFromPrintTemplate("PrintTemplateName", "entityId1", formData)
mailUtil.sendEmail("user@example.com", "Monthly Report", "<h1>Report</h1>", doc, "ProcessId:1", "WelcomeEmail")
Returns:
(void) - Sends the email with the specified attachment.Note: This is a convenience method for sending an email with a single attachment.
-
sendEmail
public static void sendEmail(String to, String subject, String htmlContent, List<com.ssgllc.fish.document.GeneratedDoc> attachments, String messageId, String interfaceMessageId) Sends an HTML email with optional attachments from GeneratedDoc holding document data in memory to the specified recipient.
If a single attachment is provided, it delegates to the multi-attachment method.
If the list of attachments is empty or null, the email is sent without attachments. An InterfaceLog record will be created for auditing and tracking, only if messageId and interfaceMessageId has values.- Parameters:
to- The recipient's email address.subject- The subject line of the email.htmlContent- The body content of the email in HTML format.attachments- A list ofGeneratedDocto be included as email attachments. Can be null or empty if no attachments are required.messageId- An identifier for the message, need not be uniqueinterfaceMessageId- An identifier for the interface where this email is sent from
Groovy example (multiple attachments):
def doc1 = bpmUtil.generateDocxDocumentFromPrintTemplate("PrintTemplateName", "entityId1", formData)Note: If an error occurs while converting attachments, the email will be sent without them and the error will be logged.
def doc2 = bpmUtil.generateDocxDocumentFromPrintTemplate("PrintTemplateName", "entityId2", formData)
mailUtil.sendEmail("user@example.com", "Reports", "<p>See attachments</p>", [doc1, doc2])
-
sendEmail
public static void sendEmail(String to, String cc, String bcc, String subject, String htmlContent, List<com.ssgllc.fish.document.GeneratedDoc> attachments, String messageId, String interfaceMessageId) Sends an HTML email with optional CC, BCC, and multipleGeneratedDocattachments to the specified recipient.
If the list of attachments is empty or null, the email is sent without attachments.
An InterfaceLog record will be created for auditing and tracking only if bothmessageIdandinterfaceMessageIdhave values.- Parameters:
to- The recipient's email address.cc- The CC (carbon copy) email address(es), can be null.bcc- The BCC (blind carbon copy) email address(es), can be null.subject- The subject line of the email.htmlContent- The body content of the email in HTML format.attachments- A list ofGeneratedDocto be included as email attachments. Can be null or empty if no attachments are required.messageId- An identifier for the message, need not be unique.interfaceMessageId- An identifier for the interface where this email is sent from.
Groovy example:
def doc = bpmUtil.generateDocxDocumentFromPrintTemplate("PrintTemplateName", "entityId1", formData)
mailUtil.sendEmail("user@example.com", "copy@example.com", "blind@example.com", "Subject", "<p>Hello</p>", [doc], "ProcessId:2", "StatusUpdate")
Returns:
(void) - Sends the email with optional CC, BCC, and attachments.Note: If an error occurs while processing attachments, the email will still be sent without them and the error will be logged.
-
sendEmail
public static void sendEmail(String to, String cc, String bcc, String subject, Map<String, Object> contextEntries, String templateName, List<com.ssgllc.fish.document.GeneratedDoc> attachments, String messageId, String interfaceMessageId) Sends an HTML email by rendering a named template with the provided context variables, and optionally includes CC, BCC, and attachments.
If the template content cannot be resolved, the method logs an error and does not send the email.
An InterfaceLog record will be created for auditing and tracking only if bothmessageIdandinterfaceMessageIdhave values.- Parameters:
to- The recipient's email address.cc- The CC (carbon copy) email address(es), can be null.bcc- The BCC (blind carbon copy) email address(es), can be null.subject- The subject line of the email.contextEntries- A map of key-value pairs used to populate the variables in the email template.templateName- The name of the HTML email template to be rendered.attachments- A list ofGeneratedDocto be included as email attachments. Can be null or empty if no attachments are required.messageId- An identifier for the message, need not be unique.interfaceMessageId- An identifier for the interface where this email is sent from.
Groovy example:
def context = [ name: "John Doe", link: "https://example.com/reset" ]
def doc = bpmUtil.generateDocxDocumentFromPrintTemplate("ResetNotice", "entityId", formData)
mailUtil.sendEmail("user@example.com", null, null, "Password Reset", context, "passwordResetTemplate", [doc], "ProcessId:3", "ResetEmail")
Returns:
(void) - Sends the email with the rendered HTML content and optional CC, BCC, and attachments.Note: If the template cannot be found or resolves to empty content, the email is not sent and an error is logged.
-