Interface EmailService


  • @ProviderType
    public interface EmailService
    A service interface for sending a generic template based Email Notification. The mailType is set to HTMLEmail by default if there are any attachments. Since we are using the template to determine the mailType, the template name has to be *.html. Here is an example to send an email with attachments: String attachment1 = "This text should be in the attache txt file." Map<String, DataSource> attachments = new HashMap<>(); attachments.put("attachment1.txt", new ByteArrayDataSource(attachment1, "text/plain")); ... ... List<String> participantList = emailService.sendEmail(htmlEmailTemplatePath, emailParams, attachments, key);
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String REPLY_TO
      Reply-TO email address variable passed in the input parameter map
      static String SENDER_EMAIL_ADDRESS
      Sender Email Address variable passed in the input parameter map to the sendEmail() function.
      static String SENDER_NAME
      Sender Name variable passed in the input parameter map to the sendEmail() function.
      static String SUBJECT
      Subject line variable used to specify the subject in the input parameter map.
    • Field Detail

      • SENDER_EMAIL_ADDRESS

        static final String SENDER_EMAIL_ADDRESS
        Sender Email Address variable passed in the input parameter map to the sendEmail() function.
        See Also:
        Constant Field Values
      • SENDER_NAME

        static final String SENDER_NAME
        Sender Name variable passed in the input parameter map to the sendEmail() function.
        See Also:
        Constant Field Values
      • SUBJECT

        static final String SUBJECT
        Subject line variable used to specify the subject in the input parameter map.
        See Also:
        Constant Field Values
      • REPLY_TO

        static final String REPLY_TO
        Reply-TO email address variable passed in the input parameter map
        See Also:
        Constant Field Values
    • Method Detail

      • sendEmail

        List<javax.mail.internet.InternetAddress> sendEmail​(String templatePath,
                                                            Map<String,​String> emailParams,
                                                            javax.mail.internet.InternetAddress... recipients)
        Construct an email based on a template and send it to one or more recipients.
        Parameters:
        templatePath - Absolute path of the template used to send the email.
        emailParams - Replacement variable map to be injected in the template
        recipients - recipient email addresses
        Returns:
        failureList containing list recipient's InternetAddresses for which email sent failed
      • sendEmail

        List<String> sendEmail​(String templatePath,
                               Map<String,​String> emailParams,
                               String... recipients)
        Construct an email based on a template and send it to one or more recipients.
        Parameters:
        templatePath - Absolute path of the template used to send the email.
        emailParams - Replacement variable map to be injected in the template
        recipients - recipient email addresses. Invalid email addresses are skipped.
        Returns:
        failureList containing list recipient's String addresses for which email sent failed
      • sendEmail

        List<javax.mail.internet.InternetAddress> sendEmail​(String templatePath,
                                                            Map<String,​String> emailParams,
                                                            Map<String,​DataSource> attachments,
                                                            javax.mail.internet.InternetAddress... recipients)
        Construct an email with attachments based on a template and send it to one or more recipients.
        Parameters:
        templatePath - Absolute path of the template used to send the email.
        emailParams - Replacement variable map to be injected in the template
        attachments - attachments map with file name
        recipients - recipient email addresses
        Returns:
        failureList containing list recipient's String addresses for which email sent failed
      • sendEmail

        List<String> sendEmail​(String templatePath,
                               Map<String,​String> emailParams,
                               Map<String,​DataSource> attachments,
                               String... recipients)
        Construct an email with attachments based on a template and send it to one or more recipients.
        Parameters:
        templatePath - Absolute path of the template used to send the email.
        emailParams - Replacement variable map to be injected in the template
        attachments - attachments map with file name
        recipients - recipient email addresses
        Returns:
        failureList containing list recipient's String addresses for which email sent failed