OpenWGA 7.5 - TMLScript reference
MailMethod :
addAttachment(file)
addAttachment(document, fileName [, altFileName])
addAttachment(inputStream, fileName)
On object | |
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 "java.io.File" 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 "java.io.InputStream" as input. The attachment name is defined by parameter "fileName". |
Parameters |
file (java.io.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 (java.io.InputStream): Variant 3: Input data as Java object java.io.InputStream fileName (String): Variant 3: File name of the mail attachment to create |
Allowed in script types |
|
Examples |
Example of Variant 1: Reads a file "thefile.txt" from file system and attaches it to a mailvar file = new java.io.File("/thefile.txt"); 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"); |