Project: Save New Email Contents to a Text File

This scenario demonstrates important workflow concepts, including decision steps and conditional transitions.

The scenario includes a workflow that checks the Outlook inbox for an email with the subject "backup" that was received close to the current time. If it finds such an email, the text in the body of that email is written to a file and the workflow ends. If no such email is found, the workflow waits for 10 seconds and then checks the Outlook inbox again.

This scenario uses the following complex variables:

  • OutlookMailItem_1: A variable of type Outlook Mail Item, which stores various values for the email including the Date, Sender, Subject, Body, etc.

  • Timer_1: A timer variable used to set an interval between polling for emails.

Download Project Files

  1. Download the project file here.

  2. Unzip and copy the files to %AppData%/Nice_Systems/AutomationStudio/Projects\

Explore the Workflow

  1. Open Automation Studio.

  2. Click Open.

  3. Select Outlook Exercise and click Open.

  4. In the Assets Panel, expand the Workflows section, and select Workflow-1.

  5. Click on the Get mail step.

    This step checks the inbox for a mail item received near the current date/time, with the subject backup, and extracts the values from the email and assigns them into the various parameters in the OutlookItem_1 complex variable. This includes the email Date, Sender, Subject, Body, etc.

  6. Click on the Dec 1 step.

    This decision step checks if the subject of the mail contains the word backup. If it does, the workflow continues to the Write to File step, otherwise it continues to the Timer step.

  7. Click on the Timer step.

    This sets the interval of the timer to 10 seconds.

  8. Click on the transition between the Timer and Get mail steps.

    Be careful to click on the transition line and not on the delete button which will delete the transition. If you accidentally delete the transition, simply reconnect the Timer and Get mail steps.

     

    The transition to the Get mail step only occurs after the timer elapses.

  9. Click on the Write to File step.

    This step creates a folder (C:\scenario) and writes the contents of the Body parameter to a file (backup_text.txt).

Test the Workflow

  1. Click Run workflow. The workflow starts to run in debug mode.

  2. In the Assets Panel, expand Workflow-2. The workflow and workflow step currently being executed are highlighted.

    The active step is also highlighted in the workflow itself.

  3. Send yourself an email with the subject backup and with any body text you choose.

  4. The workflow gets the mail, captures the information in the OutlookMailItem_01 complex variable, creates a folder (C:\scenario), and then writes the contents of the email body to the backup_text.txt file.

  5. In Windows explorer, open the folder C:\scenario and then open the file backup_text.txt in Notepad. The body text you entered is stored in the file.

  6. View the values of the changing variables in the Assets Panel. For example, you can expand the tree to view the values in OutlookMailItem_1. Note the values of Body and Conversation Topic.