Developing the content of a custom email template JSP file

You can develop dynamic and personalized email message content for your custom email template JSP file. When you are developing the content, you must adhere to certain specification rules.

About this task

To receive email activities, the customer must have opted in for marketing emails during store registration or account updates. The EmailActivityUrlHelperDataBean class gives customers a quick opt-out method.

The content of an email message is separated from the address (both the sender and recipient) and subject elements of the message. A typical example of a MIME email 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 email is distinctly separate from the header information. This separation influences software APIs and products that are developed using these email formats.

When you are creating an email template, you must adhere to the following specification rules:

Procedure

  1. If the URL query string that requests the JSP page contains the "returnSubject=true" parameter, then the JSP page should render only what would be on the subject line of the email message.
  2. If the URL query string that requests 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 email message, except for the subject line data.
  3. The URL query string that is registered as part of an email template must have the following parameters added during the request:
    recipientId
    The userID of the user for whom to generate the email.
    storeId
    The store entity ID of the store for this email template.
    activityId
    The ID of the email activity that made this request.

    These parameters are populated during email creation.

  4. If you are using IBM Digital Analytics, formerly known as Coremetrics Analytics for email activities, and a link points to the store front, it has to include the cm_cr and cm_mmc parameters, which are 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

Results

When a URL is registered to the email template, it requests various resources. By conforming to the preceding rules, you ensure that these resources provide dynamic, email 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 email templates. In practice, however, it can be much more difficult to achieve the same rich content as produced by JSP files that run within the WebSphere Commerce product.