Altova FlowForce Server 2023 Advanced Edition

The send-mime function sends an email to the specified recipients, generally to the administrator. Before using this function, you must configure the mail server settings. Unlike the send function, the Message body parameter of this function enables you to get the message body (e.g., as HTML) from a stream.


To create a stream for the message body directly in FlowForce, you can call expression functions such as stream-open or stream-from-string. You can also use MIME expression functions to customize email or attachment message headers. To prevent an email from landing into the Junk folder of the recipient, you should create MIME headers in accordance with the requirements of the receiving server or program.


To get HTML content for the message body, it is recommended to call a StyleVision Server transformation that produces HTML output as MIME. For an example that shows how to deploy a StyleVision transformation to FlowForce Server, see Create a Job from a StyleVision Transformation. For more information about StyleVision Server integration, see Integration with Other Altova Servers.


FlowForce Server does not collect any images, stylesheets, or similar resources referenced by HTML files into a MIME stream. To create the HTML message body with StyleVision Server, take the steps below:


1.Design the HTML body of an 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 on the job configuration page.

4.On 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.








Optional parameter. The sender's email address (e.g., flowforce@<hostname>).



Mandatory parameter. The recipient's email address. This field can contain a comma-separated list of email addresses.



Mandatory parameter. Subject line of a message.

Message body


Mandatory parameter. Body text of a message.


sequence of stream

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

Abort on error


Optional parameter. This parameter determines the outcome of a job in which an error has occurred. If the Abort on error parameter is true, job execution will be terminated. If the Abort on error parameter is false, FlowForce Server will ignore errors and continue job execution. The default value is true.


Example 1

The job illustrated below calls the send-mime function to send an email in HTML format.


Step 1

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. The function uses BiggesCities.xml as an input file. The output file is BiggestCitiesPerCity.html that will be generated as a MIME type (the GenerateHtmlOutputAsMime check box is selected). The result of this execution step is called output and will be used in the next step.


Step 2

The second execution step calls the compute function to compute the nth(results(output), 0) expression that picks up the MIME stream from the result generated by the previous step. The result of the second step is called message and will be used in the Message body parameter in the last execution step.


Step 3

The third execution step sends an email that has the result of the previous step (message) as the message body.



Example 2

The job illustrated below calls the send-mime function to send an email in HTML format. The email 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 is typed directly in the text box. The recommended way to get HTML output is to call a StyleVision Server transformation, as illustrated in the previous example. The result of this step is a string called body_html that will be used in the next step.


The second execution step creates the body of the email. The stream-from-string function converts the result of the first execution step to a stream. The encoding (UTF-8) and MIME type (text/html) are supplied as arguments to the function. The result of this step is message of type T0 (any type) and will be used in the message body in the last step.


The third execution step creates an attachment of the email, also as a stream. The step computes the following expression:


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


The stream-open function opens the image as a stream. The add-mime-header function adds the Content-Disposition header to the stream. The value of the Content-Disposition header is 'attachment; filename=sample.png', which indicates that sample.png can be downloaded and saved locally. The result of this step is attachment that will be used in the last step.


The last step sends an email. The send-mime function uses the result of the second step (message) as the message body. In the Attachment parameter, the mime-content-encode function is required, because sample.png is a binary file. Such files have to be encoded as Base64 in order to be preserved during transmission.


Another approach

Another approach to the job described above is to use the set-mime-content-disposition function instead of the add-mime-header function (third execution step above). The expression will look as follows:


set-mime-content-disposition(stream-open('C:\sample.png', 'image/png'), 'attachment', 'sample.png')


© 2017-2023 Altova GmbH