E-mail containing JavaScript (Advice)

You can embed JavaScript into e-mail messages composed using HTML.

When you compose and send an e-mail message, you may use HTML as a way to improve the presentation. This means you can include some JavaScript to be executed in the client mail reader application.

Not all mail clients can support HTML, let alone JavaScript. However, if your recipient does, then you can do some creative things to generate auto reply messages (security permitting). You can also do animation, play audio, present a form for a survey etc. You simply construct your HTML document in the normal way.

Server-generated mail-outs could use this technique to determine how well targeted the mailing is. Perhaps you could put a subscribe/unsubscribe button on the form and tie that to a user ID. That would get round one of the major difficulties of unsubscribing people, which is to do with the mutations that mail addresses undergo. Periodically, a mail server may move or a domain name may change, and this means that unsubscribing from the new address does not locate the subscription record that was made under an old address. Passing an ID back and forth solves this major headache.

Warnings:

See also:News posts containing JavaScript

Cross-references:

Wrox Instant JavaScript - page - 60