Creating email message JSP files
Procedure
- Option 1: The HCL Commerce JSP composes the entire HTML
and passes the HTML in one
%%BODY%%
personalization name-value pair. - Option 2: The HCL Commerce JSP creates personalization name-value pairs.
-
Create the email JSP body by using Option 1:
-
Make a copy of the existing JSP file to reuse and register it in Struts.
For more information, see Creating and registering new storefront JavaServer Pages files.
-
Open the JSP file for editing. Update it to set generic personalization name-value pairs and
set up the BODY personalization name-value pair to be created by the JSP file:
- Before the opening
<html>
tag, insert the following snippet:<jsp:useBean id="personalizationMap" class="java.util.LinkedHashMap" type="java.util.Map"/> <c:set target="${personalizationMap}" property="STORE_ID" value="${storeId}" /> <c:set target="${personalizationMap}" property="CATALOG_ID" value="${catalogId}" /> <c:set target="${personalizationMap}" property="LANG_ID" value="${langId}" /> <c:set target="${personalizationMap}" property="STORE_NAME" value="${storeName}" /> <CAMPAIGN_ID>[campaignId]</CAMPAIGN_ID> <c:if test="${!empty personalizationMap}"> <RECIPIENT> <%@ include file="../Common/SilverpopPersonalizationXml.jspf"%> <PERSONALIZATION> <TAG_NAME>BODY</TAG_NAME> <VALUE><![CDATA[ </c:if>
- After the closing
</html>
tag, insert the following snippet:<c:if test="${!empty personalizationMap}"> ]]></VALUE></PERSONALIZATION> </RECIPIENT> </c:if>
- Remove the following element:
<!doctype HTML>
- Before the opening
- Save your changes and close the JSP file.
-
Make a copy of the existing JSP file to reuse and register it in Struts.
-
Create the email JSP body by using Option 2:
-
Create the JSP file to contain the email content and register it in Struts.
For more information, see Creating and registering new storefront JavaServer Pages files.
-
Open the JSP file for editing. Update it to include the following content:
- Set up personalization map and generic
values.
<jsp:useBean id="personalizationMap" class="java.util.LinkedHashMap" type="java.util.Map"/> <c:set target="${personalizationMap}" property="STORE_ID" value="${storeId}" /> <c:set target="${personalizationMap}" property="CATALOG_ID" value="${catalogId}" /> <c:set target="${personalizationMap}" property="LANG_ID" value="${langId}" /> <c:set target="${personalizationMap}" property="STORE_NAME" value="${storeName}" />
- Add any additional custom personalization name-value pairs, such
as:
<c:set target="${personalizationMap}" property="USER_NAME" value="${WCParam.logonId}" /> <c:set target="${personalizationMap}" property="PASSWORD" value="${WCParam.logonPassword}" />
- Set up personalization map and generic
values.
-
Create the Transact XML by including the following snippet after all of the name-value pairs
have been added to the personalizationMap:
<CAMPAIGN_ID>[campaignId]</CAMPAIGN_ID> <c:if test="${!empty personalizationMap}"> <RECIPIENT> <%@ include file="../Common/SilverpopPersonalizationXml.jspf"%> </RECIPIENT> </c:if>
Note: The WC_eardir/Stores.war/storedir/EmailTemplates/Common/SilverpopPersonalizationXml.jspf file sets up values such as the email address of the recipient, and if necessary the subject, in the XML. It also parses the personalization name-value pairs set in the personalizationMap bean and places them in the XML.For example,<EMAIL>[recipientEmailAddress]</EMAIL> <BODY_TYPE>HTML</BODY_TYPE> <PERSONALIZATION> <TAG_NAME>SUBJECT</TAG_NAME> <VALUE><![CDATA[[emailSubject]]]></VALUE> </PERSONALIZATION> <c:if test="${!empty personalizationMap}"> <c:forEach items="${personalizationMap}" varStatus="pmStatus"> <PERSONALIZATION> <TAG_NAME><c:out value="${pmStatus.current.key}"/></TAG_NAME> <VALUE><![CDATA[<c:out value="${personalizationMap[pmStatus.current.key]}" escapeXml="false"/>]]></VALUE> </PERSONALIZATION> </c:forEach> </c:if>
- Optional:
Include an e-Marketing Spot.
After you include the SilverpopPersonalizationXml.jspf file, but before you close the
</RECIPIENT>
, include a<PERSONALIZATION>
section. Set the<TAG_NAME>
to be the name of the e-Marketing Spot, and use the standard method of including an e-Marketing Spot in the<VALUE>
tag.For example,<RECIPIENT> <%@ include file="../Common/SilverpopPersonalizationXml.jspf"%> <PERSONALIZATION> <TAG_NAME>EmailWishlist_Content</TAG_NAME> <VALUE><![CDATA[ <%out.flush();%> <c:import url="${env_siteWidgetsDir}com.ibm.commerce.store.widgets.ContentRecommendation/ContentRecommendation.jsp"> <c:param name="emsName" value="EmailWishlist_Content" /> <c:param name="storeId" value="${storeId}" /> <c:param name="catalogId" value="${catalogId}" /> <c:param name="isEmail" value="true" /> <c:param name="substitutionName1" value="[senderName]" /> <c:param name="substitutionValue1" value="${WCParam.senderName}" /> </c:import> <%out.flush();%> ]]></VALUE></PERSONALIZATION> </RECIPIENT>
The business user then enters
%%spotname%%
in the IBM Watson Campaign Automation email template to include the e-Marketing Spot HTML created by the e-Marketing Spot JSP file. In this example, the business user enters EmailWishlist_Content.
-
Create the JSP file to contain the email content and register it in Struts.
- Optional:
Enable the IBM Watson Campaign Automation
Click To View feature to display the email as HTML in a web browser.
Define each personalization name-value pair in the IBM Watson Campaign Automation database by including a
<SAVE_COLUMNS>
element in the Transact XML for each personalization name-value pair.The
<SAVE_COLUMNS>
element contains the personalization element. By placing an element personalization in the<SAVE_COLUMNS>
section, Engage stores the value for this field in the database associated with the Transact Automated Message Group in Engage with system field data for the record.For example,<XTMAILING> <CAMPAIGN_ID>[campaignId]</CAMPAIGN_ID> <SAVE_COLUMNS> <COLUMN_NAME>STORE_NAME</COLUMN_NAME> <COLUMN_NAME>USERNAME</COLUMN_NAME> </SAVE_COLUMNS> <RECIPIENT>
-
If you are using HCL Commerce Version 9.0.0.x, register the email JSP Struts changes
by using
-22
as the device format:<forward className="com.ibm.commerce.struts.ECActionForward" name="template_view/storeId/-22" path="template_path"> <set-property property = "interfaceName" value = "com.ibm.commerce.messaging.viewcommands.MessagingViewCommand"/> <set-property property = "implClassName" value = "com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl"/> </forward>
For example, to register the email JSP Struts changes for received orders:<forward className="com.ibm.commerce.struts.ECActionForward" name="OrderReceivedView/10101/-22" path="/EmailTemplates/Order/SilverpopOrderCreateNotify.jsp"> <set-property property="implClassName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl"/> <set-property property="interfaceName" value="com.ibm.commerce.messaging.viewcommands.MessagingViewCommand"/> </forward>
-
Register the email JSP Struts changes by using
-22
as the device format in the global result part of struts-wcs-stores-custom.xml:<result name="template_view/storeId/-22" type="wcsstore"> <param name="implClassName">com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl</param> <param name="interfaceName">com.ibm.commerce.messaging.viewcommands.MessagingViewCommand</param> <param name="location">template_path</param> </result> For example, to register the email JSP Struts changes for received orders: <result name="OrderReceivedView/10101/-22" type="wcsstore"> <param name="implClassName">com.ibm.commerce.messaging.viewcommands.MessagingViewCommandImpl</param> <param name="interfaceName">com.ibm.commerce.messaging.viewcommands.MessagingViewCommand</param> <param name="location">/EmailTemplates/Order/SilverpopOrderCreateNotify.jsp</param> </result>