Create e-mail activity templates using JSP files

This topic describes how to create an e-mail activity template. The templates are created as JavaServer Pages pages, which are capable of providing robust, dynamic, and personalized e-mail messages. E-mail templates can also be created using the WebSphere Commerce Accelerator. While this method results in more fine-grain control, it also prevents business users from making any updates, which may result in longer development cycles, or higher costs, depending on your organization. Templates created manually display in the WebSphere Commerce Accelerator, and can be selected by business users as the basis for an e-mail activity. However, you cannot edit such templates using the WebSphere Commerce Accelerator.

In order to receive e-mail activities, the customer must have a corresponding entry in the EMLUSRRECV table. If the customer does not have an entry in the EMLUSRRECV table, or if the RECEIVEEML column in that table is set to '0', the customer will not receive e-mail. That is, the customer only receives e-mail if there is a corresponding '1' in the RECEIVEEML column. A customer segment is not store-specific, therefore, an entry of '0' in the STORE_ID column represents a customer being opted-out of all e-mail activities in all stores. The Registration and Change Registration pages in the starter stores contain a field that allows customers to opt in to receiving promotional e-mail. For instructions on how to enable this field see Changing store flows

The EmailActivityUrlHelperDataBean class gives
customers a quick opt-out method.

The content of an e-mail message is separated from the address (both the sender and recipient) and subject elements of the message. A typical example of a MIME e-mail message header follows:

Received: from localhost (localhost)
    by some.address.com (1.12.256/1.12.256) id g8UG02Hj033414;
    Tue, 22 Oct 2002 14:43:22 -0400
    Date: Tue, 22 Oct 2002 14:43:22 -0400
    From: Mail Delivery Subsystem
<MAILER-DAEMON@some.address.com>
    Message-Id:
<200209301843.g8UG02Hj033414@some.address.com>
    To: <yourname@anotherAddress.com>
    MIME-Version: 1.0
    Content-Type: multipart/report; report-type=delivery-status;
    boundary="g8UG02Hj033414.1033411402/some.address.com"
Subject: Returned mail: see transcript for details
    --g8UG02Hj033414.1033411402/some.address.com

The original message was received at Tue, 22 Oct 2002 13:57:55
-0400 from 
    yet.another.address.com [256.256.256.256]

As can be seen from the areas marked in bold, the content of the e-mail is distinctly separate from the header information. This separation influences software APIs and products that are developed using these e-mail formats.

When creating an e-mail template, adhere to the following specification rules:

  1. If the URL query string requesting the JSP page contains the "returnSubject=true" parameter, then the JSP page should render only what would be on the subject line of the e-mail message.

  2. If the URL query string requesting the JSP page does not contain the "returnSubject=true" parameter (that is, it is set to anything but "true", or does not exist), then the JSP page should render the content of the e-mail message, except for the subject line data.

  3. The URL query string registered as part of an e-mail template must have the following parameters added during the request:

    recipientId

    The userID of the user for whom to generate the e-mail.

    storeId

    The store entity ID of the store for this e-mail template.

    activityId

    The ID of the e-mail activity that made this request.

    These parameters are populated during e-mail creation.

  4. If you are using Coremetrics analytics for e-mail activities, and a link points to the store front, it has to include the cm_cr and cm_mmc parameters, appended to the URL. They have the format: cm_cr=OS: Campaign Name-_-E-mail Activity-_- E-mail Activity Name-_- E-mail Template Name-_- Link Name cm_mmc=E-mail-_-Websphere Commerce-_- E-mail Activity Name-_- Link Name where E-mail Activity Name is the name of the e-mail activity, E-mail Template Name is the name of the e-mail template, and Link Name is the name of the link, uniquely identifying the link within the template. For example: https://hostname/webapp/wcs/stores/servlet/ProductDisplay?storeId=10001&catalogId=10001&productId=10001& cm_cr=OS:No+Campaign-_-E-mail+Activity-_-Summer+Discount+Activity-_-Show+Promotion-_-Desk+Special&cm_mmc=E-mail-_-WebSphere+Commerce-_-Summer+Discount+Activity-_-Desk+Special

When a URL is registered to the e-mail template, it requests various resources. By conforming to the preceding rules, you ensure that these resources provide dynamic, e-mail messages. Since all parameter data is passed by way of the URL query string, the receiving URL need not be a JSP. In fact, any resources that can read and respond according to the preceding rules can be considered valid e-mail templates. In practice, however, it can be much more difficult to achieve the same rich content as produced by JSP files running within the WebSphere Commerce product.

Store e-mail activity templates in a location that is accessible to the WebSphere Commerce Server. They must also be registered in the WebSphere Commerce database by a database administrator before they will be available to the WebSphere Commerce Accelerator.

Related concepts

E-mail activities

Related tasks

Registering an e-mail activity template

Related reference

E-mail activity delivery algorithm