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, adhere to the recommended specification rules.

To receive email activities, customers must opt in to receive marketing emails when they register or update their account. The EmailActivityUrlHelperDataBean class gives customers a quick opt-out method.

The content of an email message is separated from the addresses of both the sender and the recipient and from the subject elements of the message. A typical example of a MIME email message header can resemble the following message

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 that are 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 by using these email formats.
When you are creating an email template, you must adhere to the following specification rules:
  • If the URL query string that requests the JSP page contains the "returnSubject=true" parameter, the JSP page renders only what is on the subject line of the email message.
  • If the URL query string that requests the JSP page does not contain the "returnSubject=true" parameter, the JSP page renders the content of the email message, except for the subject line data.
  • 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.

  • If you are using IBM Digital Analytics, formerly known as Coremetrics Analytics for email activities, and a link points to the store front, the link must include the cm_cr and cm_mmc parameters. These parameters are appended to the URL with the following format.
     
    cm_cr=OS: Campaign Name-_-E-mail Activity-_-E-mail Activity Name-_-E-mail Template Name-_-Link Name 
    &cm_mmc=E-mail-_-HCL Commerce-_-E-mail Activity Name-_-Link Name
    Where
    • E-mail Activity Name is the name of the email activity.
    • E-mail Template Name is the name of the email template.
    • Link Name is the name of the link, which uniquely identifies 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 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.