SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
⤢ Open full site

Extend Outlook SDK Based Automation

In this tutorial, you will be adding functionalities to your first Outlook SDK based automation project, In the end, you will learn how to search outlook inbox or a specific email folder, retrieve email properties and download any attachments found in a specific local folder.

Overview

🎓 beginner 30 min. SAP Build Process AutomationBeginnerSAP Business Technology PlatformFree Tier

You will learn

  • How to use Outlook SDK of SAP Build Process Automation to
  • Download attachments from an email
  • Reply to an email
Ramakrishnan Raghuraman R Ramakrishnan Raghuraman September 24, 2023
Created by November 20, 2022
Contributors

Prerequisites

Steps

Intro

SAP Build Process Automation has native integration to several Microsoft Office products including Outlook, Excel SDK. In this Tutorial, you will extend additional capabilities of Outlook SDK to your automations.


Step 1 Retrieve search

As a first step, since an email search can result in multiple emails, customize your automation project to handle multiple emails in the search context.

  1. SAP Build Process Automaton comes handy with several loop controls. Add a Forever loop activity after Log Message. You can read more about it from the documentation.

    Add Forever Loop Activity
    Add Forever Loop Activity

  2. Forever loop needs to make sure it is executed until there is one email in the search result. In order to know this, use Check Current Email activity which will return if there is any pending emails in the search context. Kindly make sure to test an appropriate output parameter for this activity.

    Add Get Email In Context Activity
    Add Get Email In Context Activity

  3. The output of Check Current Email activity step is a boolean.

    Review Result of Get Boolean
    Review Result of Get Boolean

  4. The result of the previous step will return true if an email exists in the search context, stop the loop when there are no more emails to process. You use the Condition Expression Editor and include Is not or ! on the boolean output parameter from previous step. Add the given expression through the expression editor and close it.

    Add Loop Condition to Forever
    Add Loop Condition to Forever

  5. Add a Log Message that loop has reached its end. You can provide a custom message if you want.

    Log End of Loop
    Log End of Loop

  6. Add an appropriate log message to this step.

    Add Custom Log Message to End of Loop
    Add Custom Log Message to End of Loop

  7. If none of the conditions are met, the workflow of the automation will continue through the default branch. Now to the default branch, you can log the loop index first. Log Message comes handy during debugging. You may remove it, in case you no longer need them.

    Log Loop Index
    Log Loop Index

  8. You can optionally include a custom log message.

    Add Custom Message to Log Loop Index
    Add Custom Message to Log Loop Index

  9. For each email in the loop context, let us retrieve its email Subject through Get Mail Subject activity.

    Retrieve Email Subject in the search context
    Retrieve Email Subject in the search context

  10. Add a log message to print the email subject.

![Log Email Subject](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-extend-outlook-automation/10-LogEmailSubject.png)
  1. To the log message event, add your custom message
![Add A custom log message when printing email subject](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-extend-outlook-automation/11-AddLogEmailSubject.png)
  1. Add Get Next Email (Context) activity to advance the loop variable.
![Loop to next email in search context](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-extend-outlook-automation/12-GetNextEmail.png)
  1. Save and Test the automation, you should see appropriate results.
![Save and Test](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-extend-outlook-automation/13-TestAutomationExecution.png)
  1. You can include additional attributes related to your email in search context result. For example, see the various activities you can use to retrieve additional attributes in your search context.
![Validate the result](https://raw.githubusercontent.com/sap-tutorials/sap-build-process-automation/main/tutorials/spa-extend-outlook-automation/14-OtherEmailAttributes.png)

At this stage, you converted your project to process a series of emails in the search context. An Email may contain one or more file attachments. In the next step, you will download the file attachments.
Step 2 Download attachments from an email
+
Step 3 Send an email reply
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 3
1. Retrieve search 2. Download attachments from an email 3. Send an email reply

Learn more →