Package com.day.cq.commons.mail

Examples of com.day.cq.commons.mail.MailTemplate


        emailTemplatePath = this.getClass().getResource("/emailTemplate.txt").getFile().toString();

        // Mock the Mail Template
        PowerMockito.mockStatic(MailTemplate.class);
        when(MailTemplate.create(emailTemplatePath, session)).thenReturn(
            new MailTemplate(new FileInputStream(emailTemplatePath), "UTF-8"));
    }
View Full Code Here


    private Email getEmail(String templatePath, Map<String, String> emailParams) {
        ResourceResolver resourceResolver = null;
        try {
            resourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null);

           final MailTemplate mailTemplate = MailTemplate.create(templatePath, resourceResolver.adaptTo(Session.class));

           if (mailTemplate == null) {
               log.warn("Email template at {} could not be created.", templatePath);
               return null;
           }

           Class<? extends Email> emailClass = templatePath.endsWith(".html") ? HtmlEmail.class : SimpleEmail.class;

           final Email email = mailTemplate.getEmail(StrLookup.mapLookup(emailParams), emailClass);

           if (emailParams.containsKey(EmailServiceConstants.SENDER_EMAIL_ADDRESS)
                    && emailParams.containsKey(EmailServiceConstants.SENDER_NAME)) {
                email.setFrom(emailParams.get(EmailServiceConstants.SENDER_EMAIL_ADDRESS),
                        emailParams.get(EmailServiceConstants.SENDER_NAME));
View Full Code Here

TOP

Related Classes of com.day.cq.commons.mail.MailTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.