Altova FlowForce Server 2023 Advanced Edition

Full path: /system/mail/send-mime


Sends e-mail to the specified recipients, generally the administrator.


Before using this function, ensure that the mail server settings are configured (see Setting Mail Parameters).


This function returns Boolean TRUE if execution was successful. If the job execution fails, the outcome depends on the value of the Abort on error parameter, as follows:


If the Abort on error parameter is TRUE (default value), the job execution is aborted. In this case, you can still handle errors by means of protected blocks (see Handling Step Errors).

If the Abort on error parameter is FALSE, the function returns FALSE.


Unlike the send function, the Message body parameter of this function expects an expression that produces a stream, not a string. This enables you to get the message body (for example, as HTML) from a stream.


To obtain HTML content for the message body, it is strongly recommended to call a StyleVision Server transformation that produces HTML output as MIME. FlowForce Server by itself does not collect any images, stylesheets, or similar resources referenced by HTML files into a self-contained MIME stream.


In order for produce a self-contained HTML message body with StyleVision Server, do the following:


1. Design the HTML body of the email in Altova StyleVision. The design may contain local images and stylesheets.

2. Deploy the StyleVision transformation to FlowForce Server. In FlowForce, the transformation becomes a built-in FlowForce function that can be executed by StyleVision Server.

3. Create a job that calls the StyleVision Server transformation above, making sure to select the GenerateHtmlOutputAsMime option in the job configuration page.

4. In the job configuration page, call FlowForce Server expression functions to pick up the generated MIME stream and pass it to the "Message body" parameter of the send-mime function (see "Example 1" below).


If any external resources referenced by the HTML file cannot be embedded into the MIME stream, they will be added as attachments to the email.


An example job that produces HTML output as a MIME stream is illustrated below. For a step-by-step example that illustrates how to deploy StyleVision transformation to FlowForce Server, see Creating a Job from a StyleVision Transformation. For more information about StyleVision Server integration, see Integration with Other Altova Servers.


To create the stream for the message body directly in FlowForce, you can also call expression functions such as stream-open or stream-from-string. Likewise, you can use MIME expression functions to customize the e-mail or attachment message headers.


To prevent the e-mail from landing into the "Junk" folder on the recipient's side, you should construct the MIME headers in a way that is allowed by the receiving server or program.








Email address from which the e-mail message is to be sent, for example: flowforce@<hostname>.



Recipient's email address. Mandatory parameter. This field may also contain a comma-separated list of multiple destination e-mail addresses.



Subject line of the message. Mandatory parameter.

Message body


Body text of the message, as a FlowForce expression that returns a stream type.


sequence of stream

The attachment(s) sent with the email. Each attachment must be a FlowForce expression that produces a stream. Call stream expression functions to create streams from strings or files. Call MIME expression functions to add, modify, or delete MIME headers.

Abort on error


This Boolean parameter determines what should be the return value of the function if the job fails. If Abort on error is FALSE, the function will return Boolean FALSE as well. If Abort on error is TRUE, the job execution is aborted. The default value is TRUE.



Example 1: The job illustrated below invokes the send-mime function in order to send an e-mail in HTML format.


The first execution step generates HTML output by calling a StyleVision Server transformation. This transformation was designed with StyleVision and then deployed to FlowForce Server, as illustrated in Creating a Job from a StyleVision Transformation. Notice that the GenerateHtmlOutputAsMime check box is selected. Also, the result of the first execution step was called "output" (we will need this string in a subsequent step and will refer to it simply by typing "output" inside an expression).


The second execution step calls the compute function in order to compute a FlowForce expression. Namely, the expression nth(results(output), 0) picks up the MIME stream with index 0 (in this case, OutHtml) from the result generated by the previous step.


Finally, the third execution step sends the actual e-mail message. The "Message body" field also contains a FlowForce expression, which in this case is the result computed previously in step 2.


Example 2: The job illustrated below invokes the send-mime function in order to send an e-mail in HTML format that also contains an image attachment in .png format.


The first execution step prepares the HTML code for the message body. For simplicity, the HTML code in this example was typed directly in the text box. The recommended way to obtain HTML output is to call a StyleVision Server transformation, as illustrated in the previous example. This execution step produces some string output that will be used in a subsequent step.


The second execution step produces the body of the e-mail, as a stream. Namely, it converts the result of the first execution step (body_html, of type string) to a stream. The stream-from-string function was called for that purpose. The desired encoding and MIME type are supplied as arguments to the function.


The third execution step creates the attachment of the e-mail, also as a stream. The image attachment is from a local path, C:\sample.png. More specifically, this step computes the following expression:


add-mime-header(stream-open('C:\sample.png', 'image/png'), 'Content-Disposition', 'attachment; filename=sample.png')


The expression above does the following:


The stream-open function opens the image as a stream

The add-mime-header function adds the "Content-Disposition" header to the stream. This way, the image attachment will have the intended name ("sample.png").


Finally, the expression from the "Attachment" field is required because this is a binary file. Such files have to be encoded as base-64 in order to be preserved during transmission, by using the mime-content-encode expression function.

© 2016-2022 Altova GmbH