addAttachment(document, fileName [, altFileName])
Add an attachment to the mail, either from a file, a document attachment or a Java input stream
You can use this method to add attachments to the mail if you have direct access to the resource data in the available forms.
Uses a Java file object of type "java.io.File" as input. The mail attachment will take over the name of the input file.
Uses a file attachment on an OpenWGA document as source. File name optionally can be determined by parameter "altFileName".
Uses a Java input stream of type "java.io.InputStream" as input. The attachment name is defined by parameter "fileName".
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.
Variant 3: Input data as Java object java.io.InputStream
Variant 3: File name of the mail attachment to create
|Allowed in script types||
Example of Variant 1: Reads a file "thefile.txt" from file system and attaches it to a mail
var 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");