Use CaseYou want to send a document via the Mail connector with both a custom inline message body and an attachment. In the Mail operation the Disposition field allows you to select "Attachment" or "Inline" (body) but not both. However the body content can be set with a document property ahead of the Mail connector shape.
- Set the Mail operation's Disposition to "Attachment."
- Prepare the attachment as the current document data.
- Use a Set Properties shape to set the Document Property > Standard Connectors > Mail > Body property to the value of the message body.
ImplementationIn all the following examples, the Mail operation Disposition is set to "Attachment":
Note the examples also follow the best practice of setting a dynamic document property named "RECORD_ID" in the beginning of the process. This property is used to easily and consistently reference the logical record.
Simple Body ContentIf the message body content is relatively short or simple static value, set the Body property with a Set Properties step directly before the Mail connector.
Complex Body Content, Single DocumentFor more complex body content it can be easier to generate the value using a Message or even a Map shape. To accomplish this when working with a single inbound document, use a Branch shape to first create the body content on branch 1 and store the entire document contents in a dynamic process property. Then on branch 2, set the Mail connector Body property by retrieving the dynamic process property value.
Complex Body Content, Multiple DocumentsIf creating complex body content and working with multiple documents at once, follow a two-branch approach as discussed above but use a document cache instead of a process property. The document cache allows the multiple body documents to be captured and indexed by the RECORD_ID dynamic document property for correlation on branch 2. Processing the multiple records in bulk with the document cache is more efficient than using a Flow Control Run Each Document Individually shape.
IMPORTANT: There is one important configuration technique required for this approach. Because an individual profile element is used to retrieve values from a document cache, the entire message body content needs to be contained within a single profile element. In this example, this can be achieved by simply "wrapping" the text body in arbitrary XML tags and creating a single-element XML profile for use in the document cache.
- To include multiple attachments on a single mail message, zip the documents together using a Data Process Zip/Unzip Documents shape.
- In the complex, multiple document example, if the message body is XML/HTML, wrap the value in JSON syntax. You will need to use "\n" any line breaks and configure replacement parameters for the opening and closing curly braces:
6 people found this helpful