com.day.cq.commons.mail

Class MailTemplate

    • Constructor Summary

      Constructors 
      Constructor and Description
      MailTemplate(InputStream inputStream, String encoding)
      Constructs a new MailTemplate with the template text given as the inputStream and the encoding (may be null).
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static MailTemplate create(String path, Session session)
      Convenience method to create a new MailTemplate based on the path identifying the location of the email template text in the repository.
      <T extends Email> 
      T
      getEmail(StrLookup lookup, Class<T> type)
      Create an org.apache.commons.mail.Email based on the template text and replacing variables in the template text using the given lookup implementation.
    • Constructor Detail

      • MailTemplate

        public MailTemplate(InputStream inputStream,
                    String encoding)
                     throws IOException
        Constructs a new MailTemplate with the template text given as the inputStream and the encoding (may be null).
        Parameters:
        inputStream - The template text.
        encoding - The encoding of the input stream (may be null). If empty, UTF-8 will be used.
        Throws:
        IOException - If an error occurs handling the input stream.
    • Method Detail

      • getEmail

        public <T extends Email> T getEmail(StrLookup lookup,
                                   Class<T> type)
                                 throws IOException,
                                        MessagingException,
                                        EmailException
        Create an org.apache.commons.mail.Email based on the template text and replacing variables in the template text using the given lookup implementation. Emails are constructed and returned with the given type.
        Type Parameters:
        T - The email type.
        Parameters:
        lookup - The org.apache.commons.lang.text.StrLookup implementation to use for variable lookup.
        type - The class defining the email type.
        Returns:
        An email based on the template text and the variable resolver.
        Throws:
        IOException - If an error occurs handling the text template.
        MessagingException - If an error occurs during building the email message.
        EmailException - If an error occurs during building the email.
      • create

        public static MailTemplate create(String path,
                          Session session)
        Convenience method to create a new MailTemplate based on the path identifying the location of the email template text in the repository.
        Parameters:
        path - The location of the email template text in the repository. Must point to an nt:file node.
        session - The session used for accessing the repository.
        Returns:
        A mail template or null if there was an error creating the template.

"Copyright © 2006 - 2015 Adobe Systems Incorporated. All Rights Reserved"