Sample JSP code: Email template

A sample JSP email message template is provided for use as a starting point to creating custom email templates for marketing email activities. Creating a template by using this JSP code snippet is an alternative to having business users create a template within the Marketing tool.

The following procedures explain how to set up the email activity template in the development environment. After you set up and deploy the template, business users can specify the email template when they are creating email activities with the Marketing tool.

The sample EmailMessageDisplay.jsp file is available in the following directory within your development environment:
  • HCL Commerce Developer WCDE_installdir\samples\emailactivity\web

Creating a basic email template with the sample JSP code for email templates

  1. Ensure that email activity accounts are configured for your site. For more information, see Configuring email activity accounts.
  2. In a file manager utility, browse to the WCDE_installdir\samples\emailactivity\web directory.
  3. Copy the EmailMessageDisplay.jsp file.
  4. Browse to the directory where you want to store the custom template file. For example, you can store the file in the workspace_dir\Stores\WebContent\StoreDirectory\include\ directory. If the StoreDirectory directory and subdirectory does not exist, you must create these directories.
  5. Add your copied EmailMessageDisplay.jsp file into the include directory and rename the file. Change the name to be relevant to your marketing email. For example, if your email is for notifying customers about an abandoned shopping cart, you can name the file AbandonedCart.jsp.
  6. Register the JSP file as an e-mail activity template.
  7. Within your file manager utility, browse to the WCDE_installdir\samples\emailactivity\properties directory.
  8. Open the file and copy the file contents.
  9. Browse to the following directory, which includes your store properties files.


  10. Open the file for your store and add the copied content from the file. The file or a file include the text strings that make up the email content.
  11. Edit the text strings as needed to customer the content of your marketing email template.
  12. Repeat steps 7-11 to add the text strings for each locale that your store supports into the corresponding files for your store.
  13. Restart your HCL Commerce Test Server for the changes to take effect.
  14. Create a customer segment for the email activity to target if an appropriate customer segment does not exist.
  15. Create an email activity and specify the new email template by including the name of the email template that you registered it in a previous step. You can search for the email template by this name.
  16. Test your email activity to ensure that the email is successfully delivered.
  17. Deploy your changes to the production environment.

Adding an e-Marketing Spot to an email template to display marketing information within the email.

  1. If you do not already have an e-Marketing Spot to use in the template, create one by completing these procedures: When you are creating your JSP file, record the emsName parameter value that is defined in the e-Marketing Spot JSP file. You must specify this value in the email template JSP file in a following step.
  2. Create a web activity with the Marketing tool to display marketing information in the e-Marketing Spot.
  3. In your file manager utility, browse to the directory that includes the email template JSP file in which you want to add the e-Marketing Spot.
  4. Optional. If your store is a B2B store that is not a Web 2.0 store, complete the following steps:
    1. Browse to the WCDE_installdir\samples\Snippets\web\Marketing\Campaigns directory.
    2. Copy the WebServiceeMarketingSpotDisplay.jsp file. This file is a sample e-Marketing Spot code snippet.
    3. Browse to the workspace_dir\Stores\WebContent\StoreDirectory\include directory and add the file into this directory.
  5. Open your email template JSP file for editing. This file is the file that you created based on the sample EmailMessageDisplay.jsp file.
  6. Remove the following two strings from the email template JSP file.
    <%-- Remove this line to show e-Marketing Spot.
    -- Remove this line to show e-Marketing Spot. --%>
  7. Find the following line of code within the file.
    <c:param name="emsName" value="ESpot Name" />
  8. Replace the value "ESpot Name" with the value of the emsName parameter that is defined in your e-Marketing Spot JSP file.
  9. Save the email template JSP file.
  10. Test your template by creating an email activity with Management Center and specify the email template that you created.
  11. Deploy your changes to the production environment.