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:
- WCDE_installdir\samples\emailactivity\web
Creating a basic email template with the sample JSP code for email templates
- Ensure that email activity accounts are configured for your site. For more information, see Configuring email activity accounts.
- In a file manager utility, browse to the WCDE_installdir\samples\emailactivity\web directory.
- Copy the EmailMessageDisplay.jsp file.
- 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.
- 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.
- Register the JSP file as an e-mail activity template.
- Within your file manager utility, browse to the WCDE_installdir\samples\emailactivity\properties directory.
- Open the EmailActivityText.properties file and copy the file contents.
- Browse to the following directory, which includes your store properties
files.
workspace_dir\Stores\src\StoreDirectory
- Open the storetext.properties file for your store and add the copied content from the EmailActivityText.properties file. The storetext.properties file or a storetext_locale.properties file include the text strings that make up the email content.
- Edit the text strings as needed to customer the content of your marketing email template.
- Repeat steps 7-11 to add the text strings for each locale that your store supports into the corresponding storetext_locale.properties files for your store.
- Restart your HCL Commerce Test Server for the changes to take effect.
- Create a customer segment for the email activity to target if an appropriate customer segment does not exist.
- 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.
- Test your email activity to ensure that the email is successfully delivered.
- Deploy your changes to the production environment.
Adding an e-Marketing Spot to an email template to display marketing information within the email.
- If you do not already have an e-Marketing Spot to use in the template, create one by completing
these procedures:
- Create a JSP file for the e-Marketing Spot by using the sample e-Marketing Spot JSP code snippet. For more information about this sample code snippet, see JSP code snippet for e-Marketing Spots.
- Add the e-Marketing Spot to a store page. For more information, see Adding an e-Marketing Spot to a JSP store page.
- Create the e-Marketing Spot within the Marketing tool in Management Center.
- Create a web activity with the Marketing tool to display marketing information in the e-Marketing Spot.
- 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.
- Optional. If your store is a B2B store that is not a Web 2.0 store, complete the following steps:
- Browse to the WCDE_installdir\samples\Snippets\web\Marketing\Campaigns directory.
- Copy the WebServiceeMarketingSpotDisplay.jsp file. This file is a sample e-Marketing Spot code snippet.
- Browse to the workspace_dir\Stores\WebContent\StoreDirectory\include directory and add the file into this directory.
- Open your email template JSP file for editing. This file is the file that you created based on the sample EmailMessageDisplay.jsp file.
- 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. --%>
- Find the following line of code within the file.
<c:param name="emsName" value="ESpot Name" />
- Replace the value
"ESpot Name"
with the value of the emsName parameter that is defined in your e-Marketing Spot JSP file. - Save the email template JSP file.
- Test your template by creating an email activity with Management Center and specify the email template that you created.
- Deploy your changes to the production environment.