How to: Use Microsoft Power Automate to start a workflow when an email arrives in a folder in Outlook

You can use the Microsoft Outlook action in Microsoft Power Automate to start a K2 workflow when an email arrives. In this article, you create a K2 application with a SmartObject, SmartForm, and workflow, then configure a flow to start the K2 workflow and send content from your flow to the workflow using data fields.

Microsoft Power Automate starts a K2 workflow to add entries to your Leave Request emails SmartObject

See the following resources for more information:
The screenshots and instructions for third-party software are accurate at the time of writing. Third-party vendors may have changed or updated aspects of their systems (such as user interfaces, functionality, and security). As a result, this content may be outdated.

Scenario

You receive leave requests by email, and have an Outlook rule that moves them into your Leave Request folder. You want to store a list of leave request emails in a separate SmartObject. You use Microsoft Power Automate to start a K2 workflow when an email arrives in your Leave Requests folder. As part of the flow, you send the email Subject and From fields to your workflow to store in your SmartObject.

Steps

You create a SmartObject, a SmartForm, and a workflow. In the workflow you create two variables to receive the email Subject and From fields from Microsoft Power Automate. Then you configure your flow to start the workflow when a new email arrives in your Leave Requests folder. Your flow sends the From and Subject content from the email to your workflow, which creates a new entry in your SmartObject.

Before You Begin

If you have not done so already,

Setup Steps

The following steps set up the scenario from start to finish. If you already have your K2 application and want to skip the setup steps and view the topic step, go to Step 5: Create a Microsoft Power Automate flow using the Outlook When a new email arrives action to start the LeaveRequestList workflow.

  1. In K2 Designer create a SmartObject named LeaveRequestList. Add From and Subject properties. If you are not familiar with creating a SmartBox SmartObject, see How To: Create A SmartBox SmartObject.
    1. In K2 Designer click the create SmartObject option.

    2. Specify LeaveRequestList as the SmartObject name.
    3. Specify a Description and Category.
    4. Click Create.
    5. Add the following SmartObject properties:
    6. Click Finish to complete your SmartObject.
  2. Create a view of the LeaveRequestList SmartObject. If you are not familiar with creating views, see How To: Create an Item View and a List View.
    1. One the LeaveRequestList SmartObject page, click Design a new View.
    2. Specify LeaveRequest-View as the Name. Specify a Description.
    3. Leave Item View as the View Type.
    4. Click Create.
    5. Select Create Labels and Controls.
    6. Select the From and Subject fields, and the Create method.
    7. Click OK.
    8. Your view should look like this:
    9. Click Finish.
  3. Create a form for your LeaveRequest-View. If you are not familiar with creating forms, see How To: Create a Form.
    1. On your LeaveRequest-View page click Design a new Form.
    2. Specify LeaveRequest-Form as the Name.
    3. Specify a Description and click Create.
    4. Click the Title bar and specify Leave Request Emails.
    5. Click Finish.
  4. Create a workflow using your LeaveRequest-Form. In your workflow create two variables to receive the From and Subject values from an email. Add a SmartObject step to create a new entry using the From and Subject values. If you are not familiar with creating workflows, see How To: Create a Workflow.
    1. On your LeaveRequest-Form page click Design a new Workflow.
    2. Specify LeaveRequestList as the workflow name and click Create.
    3. Expand the Start Events panel (on the right) and click Edit.
    4. Click Next.
    5. Leave the default option of Do it for me! and click Next.
    6. Click Save and Finish.
    7. Click OK.
    8. Expand the Context Browser and click Add in the Variables section.
    9. Create a From and a Subject variable, both of data type Text.
    10. Back on your workflow design canvas, expand the SmartObjects > Denallix folders and drag the LeaveRequestList SmartObject onto the workflow step.
    11. In the LeaveRequestList configuration select the Create method.
    12. Click the Add icon in Input Mappings and add the From and Subject input properties.
    13. Expand the Context Browser and drag and drop your From and Subject variables to the matching input properties. This maps the data fields to the SmartObject, so when your flow starts the workflow and sends this content through, the workflow adds the information to the SmartObject.
    14. Click File. Click Deploy.

Create a Microsoft Power Automate flow that starts a K2 workflow when a new email arrives in your Outlook Leave Request folder.

This scenario is based on you receiving leave request emails in a separate folder in Outlook. If you have not already done so, create a Leave Request folder and set up an email rule to move all emails with Leave Request in the subject to your Leave Request folder.

  1. Create a flow using the Outlook When a new email arrives action to start the LeaveRequestList workflow.
    1. In Microsoft Power Automate, click Home and select the Office 365 Outlook popular service.
    2. Click When a new email arrives.
    3. If you have not already created a connection to your Outlook, log in to create this connection.
    4. Select your Leave Requests Outlook folder in the Folder drop down.
    5. Click + New Step.
    6. Specify K2 in the action search bar, then click the Start Workflow action from your K2 Connector.

    7. Select your LeaveRequestList workflow from the Workflow drop down. If you have not configured a K2 Workflow connection, complete the connection settings to create one and then make your Workflow selection.

    8. Select the folio field. Select the Expression tab and scroll down to the Date and time section. Click uctNow() and click OK. This sets the workflow folio to the time value when this flow starts the workflow.
    9. Click Show advanced options. Select the Data Field: From field. Scroll down the Dynamic content list and select From from the Outlook dynamic content. This sends the email's From value to your workflow.
    10. Do the same for the Subject data field.
    11. Click on your flow name (top right side) and specify Leave Request K2 Workflow as the name.
    12. Click Save to complete your flow.
  2. Test your flow by sending a new leave request email. Create a new SmartForm to show the list of received leave request emails.
    1. Send some leave request emails.
    2. Check your Leave Request folder in Outlook to make sure they have arrived.
    3. Check your flow Runs report to make sure that the flow has succeeded.
    4. In K2 Designer, browse to your LeaveRequestList SmartObject.
    5. Click Design a new View.
    6. Specify ShowLeaveRequest-View as the view name. Specify a Description.
    7. Select List View as the View Type.
    8. Click Create.
    9. Select the From and Subject fields.
    10. Click OK.
    11. Click Finish to complete the view.
    12. Click Design a new Form.
    13. Specify ShowLeaveRequest-Form as the form Name.
    14. Specify a Description. Click Create.
    15. Click on the Title bar and specify List of received leave request emails.
    16. Click Finish.
    17. Click Run to load the SmartForm and view the content of the SmartObject.
    18. You should see the list of received leave request emails.
Review

In this article you create a Microsoft Power Automate flow that integrates with a K2 workflow using a Microsoft Outlook When a new email arrives action. The workflow receives the From and Subject values from the email and stores them in your SmartObject.