Get Outlook Mail body as HTML in SAP Intelligent RPA
The idea of this blog post is to get the body of an outlook mail in HTML format. We will enable the function which is already available in the outlook library for SAP Intelligent RPA. Currently, we can only get the mail body in text format. At the end of this blog post, we will be able to get the mail body as both a) Text and b) HTML, formats. Let’s get started.
Pre-requisites: Basic knowledge of SAP Intelligent RPA
Enabling Outlook Library:
Enabling Outlook library is pretty easy in SAP Intelligent RPA, if you have already enabled the Outlook library, you can skip this step.
Assuming that you already have a project created,
- Head over to Scripts Tab
- Right Click on the left white-space
- From the options, choose Include library Script
- From the Add Library Script dialog box, scroll down and check Outlook Integration.
- Click Save
- After clicking Save, the bot may take some time to set up the library
- Once the bot had finished, the library can be found in the Scripts tab
Enabling getBodyHTML function:
In the outlook library, the getBodyHTML function is already available, but due to some reasons, it’s commented.
So, what we will do is, we will copy the whole outlook script and we will paste that in our very own created script and then uncomment the function. In the end, we will disable the default outlook library. So let’s get started.
- Open the outlook library
- Copy the whole code
- Right click on the white-space on Scripts area.
- From the options, choose Add a New Script
- In the New Script dialog box, Enter File Name as outlook.js and Script Name as outlook.
- Click Save
- Paste the copied code in the new script window that appears
- After pasting the code, search for the term getHTMLBody
- Uncomment the getHTMLBody function. It should look like the following.
- Save it
- Now, since our custom outlook script is done, we have to disable the default outlook library
- To do that, right click the default Outlook library, under Microsoft Office and click Exclude Script
Using the getHTMLBody in a workflow:
We can now use both the available functions and edit the workflow. More information on outlook integration can be found here.
Link to GitHub repository here.