send-mime Print this Topic Previous Page Up One Level Next page

Home >  Built-in Functions > /system/mail >


Full path: /system/mail/send-mime


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


Note: Before using this function, ensure 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.



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 body of the message. 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.


The "Message body" field contains a FlowForce expression. The expression converts the result of the first execution step (of type string) to a stream. The stream-from-string function was called for that purpose. The encoding and the desired MIME type were passed as arguments to the function.


The image attachment was taken from a local path, C:\sample.png.


Note that the image above was cut in order to fit on a print page. The "Attachment" field contains 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").

© 2019 Altova GmbH