How to Send a Mail with Both Inline and Attachment Content

Document created by Adam Arrowsmith Employee on Dec 18, 2015Last modified by ruchika_yadav on Mar 1, 2016
Version 2Show Document
  • View in full screen mode

Use Case

You 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.

Approach

  1. Set the Mail operation's Disposition to "Attachment."
  2. Prepare the attachment as the current document data.
  3. Use a Set Properties shape to set the Document Property > Standard Connectors > Mail > Body property to the value of the message body.

Implementation

In all the following examples, the Mail operation Disposition is set to "Attachment":

 

0EM40000000IEcz

 

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 Content

If 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.

 

0EM40000000IEd4

 

0EM40000000IEd9

 

0EM40000000IEdE

Complex Body Content, Single Document

For 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.

 

0EM40000000IEdJ

 

0EM40000000IEdd

 

0EM40000000IEdO

 

0EM40000000IEdT

Complex Body Content, Multiple Documents

If 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.

 

0EM40000000IEel

 

0EM40000000IEeq

 

0EM40000000IEev

 

0EM40000000IEf5

 

0EM40000000IEf0

Considerations

  • 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:
0EM40000000IEfA

 

0EM40000000IEfF
6 people found this helpful

Attachments

    Outcomes