Velocity scripting can be used inside email templates. The email variables object is available as $vars and provides access to all the contextual variables for that specific email.
Example 1 :
An example is shown below which is for program access end reminder. A program may have upto 5 end reminders (specified as comma separated days in the program settings). Note the embedded velocity scripting lines.
<template subject="Reminder __REMINDER_INDEX__ : __PROGRAM__" type="PROGRAM_SESSION_ACCESS_END"> <header> </header> <title><![CDATA[Program access ending reminder __REMINDER_INDEX__]]></title> <body> <![CDATA[Dear __FNAME__, #if ($vars.getReminderIndex() == '1') FIRST REMINDER <p>Your access to the program <a href="__URL__" target="_blank">__PROGRAM__</a> is ending on __END_DATE__. </p> #elseif ($vars.getReminderIndex() == '2') SECOND REMINDER <p>Your access to the program <a href="__URL__" target="_blank">__PROGRAM__</a> is ending on __END_DATE__. </p> #elseif ($vars.getReminderIndex() == '3') THIRD REMINDER <p>Your access to the program <a href="__URL__" target="_blank">__PROGRAM__</a> is ending on __END_DATE__. </p> #end <br/> <br/>Regards <br/>__GENERIC_SUPPORT__ ]]> </body> </template> |
Standard Objects available in the Velocity Context
Variable | Description |
vars | Email variables object that contains the information about the specific email message |
DateFormatter | Helper class to format dates |
Utility | Helper class with common utility functions |
StringUtils | Helper class with common string functions |
STRING | Static string object to help call string methods from velocity |
Example 2: Using token based direct login url in course subscription notification
To do this, override the course subscribed email template and then use the predefined variable __URL2__ instead of __URL__.
Example 3: Adding user's properties in Course completion email notification sent to Instructor -
To do this, override the course completion email template. In that all user properties default as well as all custom properties can be accessed.
Default user properties variables - Student name __SENDER__ Student Email __STUDENT_EMAIL__
Custom properties variable can be created as __up_PropertyName__ [ Change highlighted value with the user property name that is used when created the property]
Setting some variable in email template
$vars.put('DONT_SEND', true) | Don't send email, Can you used to for not sending email in for specific case. |
$vars.put('DONT_ICAL', true); | Don't include ical |
$vars.addBcc("test@edubrite.com") | For including BCC emailid. |
User Interface
- UI Customization
- Customization using Site Placements
- CSS Customizations
- Customizing Date Format
- Customize Sorting
- Customizing Labels (Captions)
- Signup Page Customization
- CMS Overview
- Getting Started with CMS
- Example of using CMS
- Catalog Customization
- Templates
Custom Properties
- Custom User Attributes
- Site level Custom Properties
- Custom property entity specific
- Multiple Languages / Default Language
- Custom File Types (Downloadable files)
Email Customization
- Email Templates Customization
- Email Override
- Email Variables
- Email Scripting - 6 Examples
- Add recommended Courses in completion email