Develop > Presentation layer > Customize marketing > E-mail activities and custom activity template JSP files
Sample JSP code: e-mail template
Use this sample JSP code snippet as a starting point to create custom e-mail templates for marketing e-mail activities. Creating a template using this JSP code snippet is an alternative to having business users create a template using the WebSphere Commerce Accelerator or Management Center user interface.
This procedure explains how to set up the e-mail activity template in the development environment so that business users can specify the e-mail template when creating e-mail activities using either Management Center or WebSphere Commerce Accelerator.
This procedure applies only to consumer direct and B2B direct store models.
This sample JSP code snippet is called the EmailMessageDisplay.jsp file and it is located at the following path:
- WCDE_INSTALL/samples/emailactivity/web/EmailMessageDisplay.jsp
Create a basic e-mail template using the sample JSP code for e-mail templates
- Make sure that e-mail activity accounts are configured for the site.
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- Locate the EmailMessageDisplay.jsp file at this path:
WCDE_INSTALL/samples/emailactivity/web/EmailMessageDisplay.jsp
- Copy the EmailMessageDisplay.jsp file to a folder in which to store the custom template, for example:
WCDE_INSTALL/workspace/Stores/WebContent/StoreDirectory/include/
- You can rename the JSP file to something relevant to the marketing e-mail, for example, AbandonedCart.jsp.
- Register the JSP file as an e-mail activity template.
- Locate the EmailActivityText*.properties file at the following path:
WCDE_INSTALL/samples/emailactivity/properties/
- Copy the content of the EmailActivityText*.properties file to the store's properties file in the store directory. The EmailActivityText*.properties file contains the strings that make up the content of the e-mail.
For example, for the Madisons starter store, the storetext*.properties files are located here:
WCDE_INSTALL/workspace/Stores/Java Resources: src/Madisons/
- Edit the strings as required to customize the content of the marketing e-mail.
- Restart the WebSphere Commerce server so that the changes take effect.
- Create a customer segment to target with the e-mail activity if an appropriate customer segment does not already exist.
- For instructions on creating a customer segment in WebSphere Commerce Accelerator, see Create a customer segment.
- For instructions on creating a customer segment in Management Center, see Create a customer segment.
- Create an e-mail activity and specify the new e-mail template using name you gave the new e-mail template when you registered it in a previous step. You can search for the e-mail template by this name.
- For instructions on creating an e-mail activity in WebSphere Commerce Accelerator, see Create e-mail activities.
- For instructions on creating an e-mail activity in Management Center, see Create an e-mail activity.
- Test the e-mail activity to ensure the e-mail is successfully delivered.
- Deploy your changes to the production server.
Add an e-Marketing Spot to an e-mail template
You can add an e-Marketing Spot to the template to display marketing information in the e-mail.
If you use WebSphere Commerce Accelerator to create e-mail activities, follow these steps:
- 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 using the sample e-Marketing Spot JSP code snippet.
- Add the e-Marketing Spot to a store page.
- Create an e-Marketing Spot using WebSphere Commerce Accelerator.
- Take note of the emsName parameter value defined in the e-Marketing Spot JSP file because specify this value in the e-mail template JSP file later in this procedure.
- Create a Web activity using WebSphere Commerce Accelerator to display marketing content in the e-Marketing Spot.
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- For B2B direct store models that are not Web 2.0 stores, complete the following substeps:
- If you do not already have an /include directory under the store's directory, create one. Here is an example of the location for this directory:
- WCDE_INSTALL/ workspace/Stores/Web Content/StoreDirectory/include.
- Copy the JSP code snippet for e-Marketing Spots (WebSphere Commerce Accelerator), eMarketingSpotDisplay.jsp, from the following directory:
- WCDE_INSTALL/samples/Snippets/web/Marketing/Campaigns
to the store's /include directory.
For other store models, the eMarketingSpotDisplay.jsp file should already exist in the store's /include directory.
- Edit the eMarketingSpotDisplay.jsp file that is in the store's /include directory.
- Find the following string; it should appear twice in the file:
<%@ include file="../../ReusableObjects/AttachmentDisplay.jspf" %>
- Replace the string with this string:
<%@ include file="AttachmentDisplay.jspf"%>
- Copy the AttachmentDisplay.jspf file from the following directory:
- WCDE_INSTALL/samples/Snippets/web/ReusableObjects
to the store's /include directory.
- Edit the e-mail template JSP file that you created.
- Delete the following two strings from the e-mail template JSP file:
<%-- Remove this line to show e-Marketing Spot.
-- Remove this line to show e-Marketing Spot. --%>
- Find the following string in the e-mail template JSP file:
<c:param name="emsName" value="ESpot Name" />
- Replace the value ESpot Name with the value of the emsName parameter defined in the e-Marketing Spot JSP file.
- Save the e-mail template JSP file.
- To test the template, create an e-mail activity with WebSphere Commerce Accelerator and specify the e-mail template that you created.
- Deploy your changes to the production server.
If you use Management Center to create e-mail activities, follow these steps:
- 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 using the sample e-Marketing Spot JSP code snippet.
- Add the e-Marketing Spot to a store page.
- Create an e-Marketing Spot using Management Center.
- Take note of the emsName parameter value defined in the e-Marketing Spot JSP file because specify this value in the e-mail template JSP file later in this procedure.
- Create a Web activity using Management Center to display marketing information in the e-Marketing Spot.
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- For B2B direct store models that are not Web 2.0 stores, complete the following substeps:
- If you do not already have an /include directory under the store's directory, create one. Here is an example of the location for this directory:
- WCDE_INSTALL/ workspace/Stores/WebContent/StoreDirectory/include.
- Copy the e-Marketing Spot code snippet for Management Center, WebServiceeMarketingSpotDisplay.jsp, from the following directory:
- WCDE_INSTALL\samples\Snippets\web\Marketing\Campaigns
to the store's /include directory.
- Rename the file from WebServiceeMarketingSpotDisplay.jsp to eMarketingSpotDisplay.jsp.
- Open the e-mail template JSP file to which to add the e-Marketing Spot.
- Delete the following two strings from the e-mail template JSP file:
<%-- Remove this line to show e-Marketing Spot.
-- Remove this line to show e-Marketing Spot. --%>
- Find the following string in the e-mail template JSP file:
<c:param name="emsName" value="ESpot Name" />
- Replace the value ESpot Name with the value of the emsName parameter defined in the e-Marketing Spot JSP file.
- Save the e-mail template JSP file.
- To test the template, create an e-mail activity with Management Center and specify the e-mail template that you created.
- Deploy your changes to the production server.
Add a content spot to an e-mail template
You can add a content spot to the e-mail template.
- If you do not already have a content spot to use in the template, create one by completing these procedures:
- Create a JSP file for the content spot using the sample content spot JSP code snippet.
- Add the content spot to a store page.
- Create a content spot using WebSphere Commerce Accelerator.
- Open WebSphere Commerce Developer and switch to the Enterprise Explorer view.
- Create a directory for the content spot under the store's directory, for example:
- WCDE_INSTALL/workspace/Stores/WebContent/StoreDirectory/Snippets/Marketing/Content.
- Copy the content spot display code snippet, ContentSpotDisplay.jsp, from the following directory:
- WCDE_INSTALL/samples/Snippets/web/Marketing/Content/
to the store's /Snippets/Marketing/Content directory.
- Edit the ContentSpotDisplay.jsp file.
- Find the following string in the ContentSpotDisplay.jsp file. It should appear twice in the file:
<%@ include file="../../ReusableObjects/AttachmentDisplay.jspf" %>and replace it with:
<%@ include file="AttachmentDisplay.jspf"%>
- Copy the AttachmentDisplay.jspf file from the following directory:
- WCDE_INSTALL/samples/Snippets/web/ReusableObjects
to the store's /Snippets/Marketing/Content directory.
- Edit the e-mail template JSP file that you created.
- Find the following string in the e-mail template JSP file:
<fmt:message key="EmailMessageDisplay_Para3" bundle="${emailMessageText}" />
- Above the string, insert:
<c:import url="${sdb.jspPath}/Snippets/Marketing/Content/ContentSpotDisplay.jsp"> <c:param name="spotName" value="ContentSpot Name" /> </c:import>
- Replace the value ContentSpot Name with the value of the spotName parameter defined in the content spot JSP file.
- Save the e-mail template JSP file.
- To test the template, create an e-mail activity and specify the new e-mail template.
- Deploy your changes to the production server.
Related tasks
Register a custom e-mail activity template
Develop the content of a custom e-mail template JSP file
Related reference
E-mail activity delivery algorithm