Using Email Templates Extensions

A special folder in the Templates folder, named Extensions contains extension
scripts that provide new, custom template elements. These extensions may be
called from within the inline scripts created in
the other templates. The scripts are provided inside messages. The body of the
messages is evaluated every time an unknown template element is encountered in
a template. Within extensions, you can create new elements and new procedures.

Extensions do not function as templates by themselves, and the elements and
procedures created in them must be activated by a template. With the following
examples, a sample template is provided with each extension, so that you can
see how each extension works.

Extension Examples

Calling template procedures

Custom elements that require script processing, are provided via Tcl procedures
that start with etx_. The rest of the procedure name is the name of the new
template element. The procedure will be called every time the element is
encountered in a template, and the element name will be substituted with the
value returned by the procedure. In general, if you find yourself creating the
same scripts again and again within your templates, you may want to store that
script as a procedure within the extensions folder.

For example, for a custom element named ¤t_time;, a procedure of the following
form must be provided:

Working with external applications

Tcl cooperates with local files and applications just as easily in extensions as
with inline scripts.

This extension demonstrates how to invoke an external application from a
template. Let's assume you have an application called salesapp.exe that
provides the current sales performance data when invoked. To insert these data
directly into a message, you could write an extension as follows:

proc etx_sales_data {args} {
return [exec salesapp.exe]
}

That's it! (You might have to include extra arguments to your salesapp.exe, but
that's beyond the scope of this simple example).

Processing an Order

This example demonstrates how you may access the different data fields specified
in an email. A sample file is provided below to illustrate this. The extension
will parse the email and add new template elements for each data field.

Note: This extension requires that you know about the specified format of the
data in the email. In other words, it can be modified to work for most
situations, but was written based on a message of the following format:

Bulk Email

This example demonstrates how to send an email to all the subscribers on your
company mailing list. Email Templates™; will personalize each email for your
subscribers so that it does not appear that they are receiving a bulk email.
You supply Email Templates™ with the location of your subscribers list, create
the message to be sent, and select the Bulk Email Template.

This extension example demonstrates how Email Templates™ can handle the
repetitive task of sending email to a company's subscriber list. This extension
can prove extremely useful when you need to send out that monthly electronic
news letter or new product announcement to your subscribers. You provide the
body of the message and the location of the subscribers file, and the extension
will take care of the rest.

This example demonstrates how to access each column of data from a tab separated
file. (i.e. Microsoft Excel) And, if you decide to add some new information to
your file, the code will take care of the change itself and give you access to
the new data. There is no need to make any changes to the code, simply modify
your data by adding another tab separated column.