Creating e-mail activity templates

E-mail activity template creation is a task for Web designers. The templates are created as JavaServer Pages so they use a familiar programming tool, which is capable of providing robust, dynamic, and personalized e-mail messages. There are a few details of which Web designers should be aware when creating e-mail templates.

Due to the nature and history of e-mail message formats (for example, MIME), 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 which are developed on top of these e-mail formats.

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

  1. If the URL query string requesting the JSP contains the "returnSubject=true"  parameter, then the JSP should render only what would be on the subject line of the e-mail message.
  2. If the URL query string requesting the JSP does not contain the "returnSubject=true" parameter (that is, it is set to anything but "true", or does not exist), then the JSP 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 message data
    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. These parameters should be exhaustive enough to permit the JSP author to drop any databean onto the template they want in order to achieve the desired content.

Conformance to the above rules ensures that the resources requested by the URL registered to the e-mail template will provide rich, dynamic, e-mail messages. It is also worth noting that because all parameter data is passed by way of the URL query string, the resource on the other end of the URL need not be a JSP. In fact, any resources that can read and respond according to the above rules may be considered valid e-mail templates. In practice, however, it may be much more difficult to achieve the same rich content produced by JSP files running within the WebSphere Commerce product.