E-Mail Send/Receive Application

The E-Mail Send/Receive application allows to send and receive e-mails.


Figure: Properties - Email Application

Setting E-Mail Send/Receive Application Properties

Apart from the common properties, the following property tabs are provided for an E-Mail Send/Receive application:

Parameters

Predefined IN access points are created for to, from, cc, bcc and subject. You cannot create OUT access points. If IN data mappings are defined on predefined IN access points for meta-information, then at runtime available value overwrites the value defined in the UI. However, the OUT access point returnValue (String primitive) is created as soon as a response type is selected.

Accessing the parameters in data flows

The default and added parameters can be set as input access points in data flow to the E-Mail application.

Application Context for Mail Applications
Figure: Mail Application access points

Response

The http response type is supported which allows correlating back process data information via MailReceptionServlet. The http response type requires a server base URL. For example, http://myippruntime/mycontextroot. The E-Mail Overlay is implemented as asynchronous Camel application type if a response type is selected.


Figure: Response

The http response type requires an Enumeration type (SDT of type Enumeration) where each element in the Enumeration becomes a link in the email (e.g. Approved, Rejected, etc).


Figure: Response

Configuration

You can use configuration variables for user and password.


Figure: Configuration

The e-mail editor is provided to format and write email contents. You can format an email using the following icons:

Icon Function Description
Source Displays source of the content
Cut Using this icon you can move the content. It is enabled when some text is selected in the editor.
Copy Using this icon you can copy the cut or selected content in the editor. It is enabled when some text is selected.
Paste Using this icon you can paste the copied or cut content in the editor.
Paste as Plain Text Using this icon you can paste the copied content as plain text.
Paste from Word Using this icon you can paste the copied content from Microsoft Word.
Undo/Redo Using this icon you can undo or redo the most recent action taken.
Spell-check Enables you to check the spellings in the content.
Bold, Italic, Strike Through, Remove Format Applies bold, italic, strike through formatting or removal of formatting to selected text.
Insert/Remove Numbered List Inserts or removes numbered list
Insert/Remove Bulleted List Inserts or removes bulleted list
Increase or Decrease Indent Increases or decreases the text indentation.
Block Quote Format a block of text to identify quotations.
Link, Unlink and Anchor Adds link to the selected text or unlink the linked text or provide anchor for the text.
Image Inserts an image at specified location.
Table Inserts a table at specified location.
Horizontal Line Inserts horizontal line at specified location.
Special Character Inserts special characters at specified location.
Styles Enables you to specify styles for the content.
Format Paragraph Enables you to format paragraph of the content.
Maximize Increases the size of the editor.
About CKEditor Displays information about editor.

Test

You can test the application in this tab. Click Reset to initialize the input data and then click Run.


Figure: Resulting Test email

You can view the email content to be sent. If you have provided response type as HTTP then the data values provided in the enumeration type are displayed as links.


Figure: Test email with options to select

Attachments

You can add customized templates for attachments. The templates source could be:

For the embedded attachments, the details below should be defined.


Figure: Attachment templates configuration


Figure: Document repository

More details about template creation are described here.

Loading a Template Location dynamically

In many situations, the end user would like to specify the attachments and templates dynamically at runtime.

The following model shows how to do that. It has a manual activity where details for structured data Person and TemplateConfiguration are entered. In the second activity, an email application is invoked using the entered data.


Figure: Dynamic email attachments model

Below the main steps to create the model.

  1. Create a SDT for the template configuration as follow:


    Figure: TemplateConfiguration structured data

    The SDT is a list of attachments with the attributes below:

  2. Create and configure an email application.
  3. Add a new parameter with direction In of the structured data type Person.


    Figure: Enter a parameter for Person

  4. In the process diagram canvas click the data flow of the TemplateConfiguration to the mail application and select Mail Attachments as input access point.


    Figure: Select input access point

  5. In the process diagram canvas click the data flow of data Person to the mail application and select Person as input access point.


    Figure: Select input access point for Person

  6. In the Templates tab, enter the following source code:
    Dear Mr. {{Person.Firstname}} {{Person.Lastname}}!


    Figure: Code entered for Email content

Running the example

Deploy the model and start the created process. Proceed as follows:

  1. Enter details for data Person and the following attachment configuration:


    Figure: Dynamic Template runtime

  2. An email with the following content is sent having a PayForm.pdf file as attachment.


    Figure: Email sample with dynamic attachment

Note
If the T Template check box is not selected, the file will not be attached to the email!

Using Attachments/Templates derived from Process Data

The attachment tab allows to define documents to be attached to the e-mail sent. Those documents have usually being processed by a template engine where the template is located in the document repository or class path and the actual values are derived from process data. This example explains how attachment documents could be derived from process data and sent as e-mail attachment too.

Our example model has a manual activity where details for a structured data Person and two templates are entered. In the second activity, an email application is invoked using the entered data.


Figure: Templates derived from process data model

Set up the model as follows:

  1. Add two templates (document type) defined as IN parameters.


    Figure: Email template Parameters

  2. The two document types defined as IN access point are listed in the Attachments tab with value Data for Source and an empty field for Path.
  3. Add two further templates, one located in the repository and one in your classpath.


    Figure: Email template Attachments

  4. Set the input access points for the incoming data to the input parameters of the Mail application accordingly.


    Figure: Input Access Points

To test the example model, deploy the model and start the process. Enter details for Person and upload the template files.


Figure: Email template Data Attachments Runtime

An email similar as in the following screenshot is sent having four files attached.


Figure: Email sample with process data attachment

Using Correspondence Attachments

To manage the correspondences with their clients, Clerks or Business Analysts want a model to indicate which documents are received, which one are missing, etc. In many cases, they want to send an email to:

To achieve this task, E-Mail applications have been extended to derive attachments from a process data of type CORRESPONDENCE.

You can download the predefined CORRESPONDENCE.xsd data type from here:
CORRESPONDENCE.xsd.

The CORRESPONDENCE structured data type has a list of CORRESPONDENCE_ITEM attributes. For details on this data, please refer to chapter Using the predefined Structured Data Type for Correspondence in the End User Handbook.

Each CORRESPONDENCE_ITEM has the following attributes:

Name Type Cardinality Description
Name Text Exactly One The correspondence name
TemplateID Text Exactly One Document ID for outgoing template. Templating should be run if TemplateID is not null and OutgoingDocumentID is null.
OutgoingDocumentID Text Exactly One Document ID for outgoing document i.e. contains results after Templating
IncomingDocumentID Text Exactly One Used only by Document Triage UI
ConvertToPDF Boolean Exactly One If true convert the attachment to PDF before sending it (after processing it as template if applicable).
IsAttachment Boolean Exactly One Determines whether the document should be attached to the email or not
Required Boolean Exactly One Determines whether the document is required or not
Accepted Boolean Exactly One Determines whether the document is accepted or not
Comment Text Exactly One A comment about the document (i.e: "Please provide new driver license. The one you provided is expired")
ACL Text Exactly One List or roles with read/modify/delete rights
RequestedDate Date Exactly One Document requested date
ReceivedDate Date Exactly One Document received date
DocumentTypeID Text Exactly One DocumentType to be used for incoming document (used by Document Triage UI)
DocumentDataPathID Text Exactly One Document "slot" to be used for incoming document e.g. PROCESS_ATTACHMENTS (used by Document Triage UI)


Figure: CORRESPONDENCE ITEM Structured data

Templating

The CORRESPONDENCE data can be used in an email template to access data on all attached documents.

The following example shows how to loop over the documents and access some of their attributes

#foreach ($item in $CORRESPONDENCE.Documents)
	Document: $item.Name
	Comment:  $item.Comment
	Accepted: $item.Accepted
	Required: $item.Required
	DocumentType: $item.DocumentTypeID
#end

Example

The following example illustrates how to use the correspondence documents with email application.

Requirements

The following configuration is required for using the templating functionality:

Camel Context Adjustments

To use templating functionality, you have to add the defaultTemplatingRoutes context reference to your Camel Context file (e.g.:default-camel-context.xml file under the stardust-engine-camel-config.jar file in META-INF/spring directory.)

<camelContext id="defaultCamelContext" trace="true"
   xmlns="http://camel.apache.org/schema/spring">
      <routeContextRef ref="defaultTemplatingRoutes"/>
</camelContext>