Customers can modify existing email templates or add new email templates that can be used to send emails from CloudPortal Business Manager.
- Log in to CloudPortal Business Manager UI a ROOT user.
- Navigate to Administration > Content Templates.
- Select the category of content templates that you want to modify.
- Select any template from the list of templates (in the left pane).
- Move the cursor over the manage icon (that looks like a gear wheel) and click Edit.
A dialog box opens that contains the code for the template.
- Make the changes as required and click OK.
This modified template can now be used to send emails. This template gets persisted into the DB so it does not get reverted when CloudPortal Business Manager is re-started.
To add new templates, you must have the development setup as described in Installing and building custom components.
- Add new templates in liquibase xml file located in citrix.cpbm.custom.common bundle located at src/main/resources/citrix/cpbm/custom/db/portal/custom-db-config-v0.1.xml.
A sample liquibase change set for adding a custom email template will look as follows:
- In code, an email template can be sent using emailService as shown below:
/** * @param template - the template location * @param model - model object required for the template * @param subjectKey - key code in messageSource for the subject * @param user - user to him the email has to be sent */ public void sendEmail(final String template, final Map<String, Object> model, final String subjectKey, final String toAddresses); eg: Map<String, Object> model = new HashMap<String, Object>(); model.put("locale", LocaleUtils.toLocale(config.getDefaultLocale())); model.put("user", user); emailService.sendEmail("SAMPLE_TEMPLATE", model, "email.template.SAMPLE_TEMPLATE.subject", <email addresses>);Note: The above code uses the same value of template_name as provided in Step 1.
Service provider can choose not to send email associated with any email template by simply making the content of the email template as NULL or empty. When content of any email template is nullified, then the email is not sent and is ignored.