It is convenient to use the same method to construct documents that the SMTP handler uses, which is a combination of style sheets, template documents, and replacement data. To do this, you must obtain the style sheets and template documents, and invoke the style sheet processor programmatically.
The sample code found in SampleCommandHandler.java illustrates this process.