OpenWGA 7.9 - TMLScript reference

Method :

addAttachment(document, fileName [, altFileName])
addAttachment(inputStream, fileName)

On object Mail
Usage Add an attachment to the mail, either from a file, a document attachment or a Java input stream
Description You can use this method to add attachments to the mail if you have direct access to the resource data in the available forms.

Variant 1:
Uses a Java file object of type "" as input. The mail attachment will take over the name of the input file.

Variant 2:
Uses a file attachment on an OpenWGA document as source. File name optionally can be determined by parameter "altFileName".

Variant 3:
Uses a Java input stream of type "" as input. The attachment name is defined by parameter "fileName".
Parameters file (
Variant 1:
The input file

document (WGAPI-Objekt WGDocument):
Variant 2:
The document which contains the attachment to use

altFileName (String, Optional):
Variant 2:
Alternative file name for the mail attachment. If not specified it will have the same name as the document attachment used for input.

inputStream (
Variant 3:
Input data as Java object

fileName (String):
Variant 3:
File name of the mail attachment to create
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Examples Example of Variant 1: Reads a file "thefile.txt" from file system and attaches it to a mail

var file = new"/thefile.txt");
var mail = createMail();

Example of Variant 2: Use a file "thefile.txt" that is attached to a file container as input for a mail attachment:

var fc = db().getFileContainer("files");
var mail = createMail();
mail.addAttachment(fc, "thefile.txt");