How email functions are implemented in K2

  • 16 February 2021
  • 0 replies
  • 1120 views

Userlevel 5
Badge +20
 

How email functionality is implemented in K2 Five and K2 Platform Classic

KB003440

PRODUCT
K2 Five

 

This article describes how email functions are implemented in K2. Sending of emails in K2 surface in multiple areas, such as in SmartForms Rules, Workflows Steps, and SmartActions. You can refer to the diagrams and step explanations in this article to better understand how email is handled in K2.

The following table displays whether you can change the Provider and From Address in each scenario.

Scenario Can you change the Provider? Can you change the From Address?
SmartForms: Send an E-mail action Yes Yes
Workflow: Send Email Step Yes Yes
Workflow: Task Notification Yes Yes
Workflow: SmartActions Replies Yes (with limitations) No
 
 
SmartForms: Send an E-mail Action

This section describes how the Send an Email Action rule in SmartForms works.

Figure 1: SmartForms: Send an E-mail action (Click to enlarge image)

  1. The Send Email action executes on the SmartForm.
  2. A web service call is made to IIS.
  3. The web service connects over TCP using Port 5555 to the SmartForms Runtime Hosted Service.
  4. The SmartForms Runtime Hosted Service executes the relevant method in the MessageBus Service.
  5. Depending on whether you are using Microsoft Exchange (EWS) or SMTP, the relevant K2 Library (K2 IMAP or K2 EWS) executes.
    • If EWS, the K2 EWS Library makes a web service call to the Mail Server to send the email.
    • If SMTP, the K2 IMAP Library makes a connection over TCP to Port 25 to the Mail Server to send the email.

Changing the Provider

You can change the Provider in the ConnectionStringEditor.exe ([K2 Installation Directory]K2Host ServerBinConnectionStringEditor.exe) tool, and by editing the sourceCode.smartactions.directoryCatalog entry in the K2HostServer.exe.config([K2 Installation Directory]K2Host ServerBinK2HostServer.exe.config) file.

Changing the From Address

You can change the From Address in the Send an Email action in K2 Designer

If you specify a sender's email address in the From field, ensure that the K2 service account has permission to send email on that address's behalf. This is typically done by granting Delegate Rights for the K2 service account to send the email on behalf of the other email address. For more information on Delegate Rights see the Allow someone else to manage your mail and calendar article from the Microsoft Office support site.
 
Workflow: Send Email Step

This section describes how the Send Email step in a workflow works.

Figure 2: Workflow: Send Email Step (Click to enlarge image)

  1. A workflow instance is started on a workflow that contains a Send Email step.
  2. When a Send Email event is detected, the Workflow Event Execution executes the relevant method in the Workflow Shapes Library. (The workflow Shapes Library is the code associated with various types of workflow steps).
  3. The connection strings are checked to determine whether EWS or SMTP is used in the executing K2 environment.
    • If EWS, the K2 EWS Library makes a web service call to the Mail Server to send the email.
    • If SMTP, the K2 IMAP Library makes a connection over TCP to Port 25 to the Mail Server to send the email.

Changing the Provider

You can change the Provider in the ConnectionStringEditor.exe ([K2 Installation Directory]K2Host ServerBinConnectionStringEditor.exe) tool.

Changing the From Address

You can change the From Address by editing the Connection String in the ConnectionStringEditor.exe ([K2 Installation Directory]K2Host ServerBinConnectionStringEditor.exe) tool, editing the sendmailfrom value in the K2HostServer.exe.config file, and by editing the From Address value in the Environment Library node in K2 Management.

The mail account added as the new From Address requires specific K2 Service and Exchange permissions and rights. See the Required Permissions topic for more information.
If you change the From address, ensure that the K2 service account has permission to send email on that address's behalf. This is typically done by granting Delegate Rights for the K2 service account to send the email on behalf of the other email address. For more information on Delegate Rights see the Allow someone else to manage your mail and calendar article from the Microsoft Office support site.

 
Workflow: Task Notification

This section describes how the Task Notification email works, when you use this option in the User Task step.

Figure 3: Workflow: Task Notification (Click to enlarge image)
tasknotificationlrg.png

 

  1. A workflow instance starts.
  2. When a Task event with task notifications enabled is reached, the Workflow Event Execution executes the relevant method in the Workflow Shapes Library.
  3. The Workflow Shapes library executes the relevant method to the EventBusClient API, and the data is inserted from the task notification into the [EventBus][CustomEventInstance] and [EventBus][EventPolicyMappingInstance] tables in the K2 database. The data includes the body of the mail, subject, and so forth.
  4. Once the data has been added to the K2 database, the Workflow Event Execution goes into a waiting state, where it waits for the user to action the task.
  5. The EventBus Hosted Service checks the [EventBus][CustomEventInstance] and [EventBus][EventPolicyMappingInstance] tables in the K2 database every thirty seconds for new mail entries.
  6. When new mail entries are identified and retrieved, the EventBus Hosted Service executes the relevant method in the MessageBus Service.
  7. The connection strings are checked to determine whether EWS or SMTP is configured.
  8. Depending on whether you are using EWS or SMTP, the relevant K2 Library (K2 IMAP or K2 EWS) executes.
    • If EWS, the K2 EWS Library makes a web service call to the Mail Server to send the email.
    • If SMTP, the K2 IMAP Library makes a connection over TCP Port 25 to the Mail Server to send the email.

Changing the Provider

You can change the Provider in the ConnectionStringEditor.exe ([K2 Installation Directory]K2Host ServerBinConnectionStringEditor.exe) tool.

Changing the From Address

You can change the From Address by editing the Connection String in the ConnectionStringEditor.exe ([K2 Installation Directory]K2Host ServerBinConnectionStringEditor.exe) tool, editing the sendmailfrom value in the K2HostServer.exe.config file, and by editing the From Address value in the Environment Library node in K2 Management.

The mail account added as the new From Address requires specific K2 Service and Exchange permissions and rights. See the Required Permissions topic for more information.
If you change the From address, ensure that the K2 service account has permission to send email on that address's behalf. This is typically done by granting Delegate Rights for the K2 service account to send the email on behalf of the other email address. For more information on Delegate Rights see the Allow someone else to manage your mail and calendar article from the Microsoft Office support site. If you use an alternate From email, note that SmartActions will not function since reply emails are sent to the alternate From email and not to the one configured for SmartActions.

 
Workflow: SmartActions Replies

This section describes how K2 handles emailed replies when Task Notifications are configured for SmartActions.

Figure 4: Workflow: SmartActions Replies (Click to enlarge image)
smartactionsreplieslrg.png

 

  1. The task recipient receives the task notification email, and replies to the email with one of the available SmartAction options.
  2. The email is sent to the SmartActions Inbox, where the EWS Mail Server checks for new e-mails.
  3. The EWS SmartActions receiver executes a web service call every 30 seconds to the Mail server, as instructed by the MessageBus service, to retrieve the relevant emails.
  4. The MessageBus retrieves the message from the SmartActions Inbox and passes it onto the SmartActions Library.
  5. The SmartActions Library retrieves the serial number and [Action] keyword from the email content, and sends it to the Workflow Server Action Task library. Assuming the task, serial number and email origin matches the task notification configuration, the workflow continues with the specified task action.
  6. The Workflow Server Action task returns the result of the action to the SmartActions Library, and the message is relayed to the MessageBus Service.
  7. Depending on the settings within your connection strings (SMTP or EWS), the relevant method is invoked to the respective library.
    • If EWS, the K2 EWS Library makes a web service call to the Mail Server, and sends the email to the recipients inbox.
    • If SMTP, the K2 IMAP Library makes a connection over TCP to Port 25 to the Mail Server and sends the email to the task recipients inbox.

Changing the Provider

Only EWS supports sending and receiving SmartActions emails. If necessary, you can configure the Provider for SmartActions by editing the ConnectionString and sourceCode.smartActions.directoryCatalog values in K2HostServer.exe.config file, but bear in mind that doing so may break the SmartActions functionality in your environment.

 

 


0 replies

Be the first to reply!

Reply