The page template for your targeted e-mail is specified by the templateURL property of the TemplateEmailInfoImpl object. You create this template like any other page. Because the template page is passed to the standard ATG servlet pipeline, it can include ATG servlet beans and additional JHTML or JSP tags.

Here is a sample JSP targeted e-mail template. It displays a few profile attributes and contains a targeting servlet bean. Assuming the targeting rules used in the TargetingForEach servlet bean’s targeter service depend on the attributes of the Profile component, the targeting results displayed in the e-mail message will be different for each profile.

<dsp:importbean bean="/atg/userprofiling/Profile"/>

<p>Dear <dsp:valueof bean="Profile.firstName"/>
<dsp:valueof bean="Profile.lastName"/>,

<p>Thank you for your order! It has been shipped today to:

<dsp:valueof bean="Profile.address"/><br>
<dsp:valueof bean=""/>, <dsp:valueof bean="Profile.State"/>
<dsp:valueof bean="Profile.zipCode"/>

<p>Since your last order, we've introduced some great new products. If you enjoy
your new <dsp:valueof bean="Profile.lastProductShipped"/>, you may also be
interested in ordering some of these great widgets:<p>

<dsp:droplet name="/atg/targeting/TargetingForEach">
  <dsp:param bean="/targeters/WidgetTargeter" name="targeter"/>
  <dsp:oparam name="output">
    <dsp:valueof param=""/><br>

<p>Thank you for shopping with us.

The Customer Service Team

Note that if your template page contains links to other URLs on your site, you must specify them as absolute URLs; otherwise the e-mail recipients will not be able to access the linked pages. Use the full http://server:port/... form of the URL. For example, in JSP code:

<dsp:img src="http://myserver:80/images/logo.gif">
<dsp:a href="http://myserver:80/help/index.html">help</dsp:a>

The following example will not work, because it uses relative URLs:

<dsp:img src="images/logo.gif">
<dsp:a href="help/index.html">help</dsp:a>
Specifying E-mail Fields in the Template

By default, the Personalization module takes the values for various fields of an e-mail message from properties of the TemplateEmailInfoImpl object. This behavior means that all messages using the same object will have identical properties. For example, suppose the value of the messageSubject property of the TemplateInfoImpl component is “Hello”. All e-mail messages created by this component will contain the subject line “Hello”.

You can override the values of these properties in a specific e-mail template by doing the following:

For example, you can set a different subject line for a specific mailing by including a statement as follows in the template for that mailing:

JSP example:

<dsp:setvalue value="Your order has shipped" param="messageSubject"/>

JHTML example:

<setvalue param="messageSubject" value="Your order has shipped">

Because these parameters are evaluated for each message individually, they can include dynamic content. For example, you could set the message subject as follows.

JSP example:

<dsp:setvalue value='<%="Order " + request.getParameter("")+
" has shipped"%>' param="messageSubject"/>

JHTML example:

<setvalue param="messageSubject"
  value="Order 'request.getParameter("")' has shipped">

There are seven parameters that you can use in this way to override the corresponding TemplateEmailInfoImpl properties:

You can use any combination of these parameters in an e-mail template; if any of these parameters is not set, the system uses the corresponding property value instead.

For example, you could globally set the messageCc property to Cc yourself, but you could override this property if you wanted to Cc or Bcc other people to make them aware of a particular e-mail campaign. The messageCc and messageBcc parameters are defined as a string of e-mail addresses separated by commas. For example, you could add the following lines to a template file.

JSP example:

<dsp:setvalue value=,

JHTML example:

<setvalue param="messageCc",>
<setvalue param="messageBcc",>

Note: Property values you set through an e-mail template are not persisted to the database. Only the values that are set in the TemplateEmailInfoImpl object are persisted.