Skip to Content
Technical Articles
Author's profile photo Peter Urbanek

Cloud Integration – Sending email from Microsoft 365 to SAP Backend in private network using SAP Cloud Connector

The topic

Recently I was participating on a project for a customer. One of the issues we faced was how to connect e-mails from Microsoft 365 with an SAP backend. The problem was that backends are in company’s inner network not reachable from the outside world.

We came with a solution to use SAP Integration Suite. Backend servers are already connected to SAP Businness Technology Platform through SAP Cloud Connector.

In this blog I’m going to describe the solution.

Prerequisites

First of all, I suggest you to read this great blogpost by Franz Forsthofer https://blogs.sap.com/2020/08/20/cloud-intgration-connect-to-microsoft-365-mail-with-oauth2/. Our solution is basically an extended version of Franz’s solution.

As prerequisites you need to prepare Microsoft Azure Active Directory. It is described in Frank’s blog in parts Create OAuth Client/App in Microsoft Azure Active Directory and Create an OAuth2 Authorization Code Credential in SAP CPI Tenant.

Configuration of the SAP Cloud Connector

As first step we need to have working SMTP connection to SAP backend from SAP BTP subaccount where SAP Integration Suite is subscribed.

SAP%20Cloud%20Connector%20configuration

SAP Cloud Connector configuration

Create new Cloud to On-Premise connection type Non-SAP System and TCP protocol. You need to specify SMTP port of the backend system you want to send e-mails to. Of course, this SMTP port have to be configured on the system. You can see port number in the transaction SMICM. As the virtual port you can chose any.

Cloud%20Connector%20configuration

Cloud Connector configuration

 

The Solution

Configure the Mail Sender Adapter in an Integration Flow

For a communication to Microsoft 365 the Mail Sender Adapter is used. Configuration parameters are also described in the Franz’s blogpost.

Mail%20Sender%20Adapter%20configuration

Mail Sender Adapter configuration

Basically, you need to just configure Microsoft 365 SMTP address and provide Credential Name for Authentication created earlier as a part of prerequisite.

Enter the Address value “outlook.office365.com:993“. In the “Connection” tab, choose “OAuth2 Authorization Code” as “Authentication”. Protection must be defined as “IMAPS” for Microsoft 365.

Mail Sender Adapter configuration

 

Configure the Mail Receiver Adapter in an Integration Flow

In this part we are going to configure connection to the SAP backend using SAP Cloud Connector.

Mail%20Receiver%20Adapter%20configuration

Mail Receiver Adapter configuration

On the tab Connection we need to provide Address of the Virtual Host and Location ID for Cloud Connector we’ve configurated earlier. You can find it also in SAP BTP Cockpit under tab Connectivity – Cloud Connectors

SAP%20BTP%20Cloud%20Connectors%20tab

SAP BTP Cloud Connectors tab

 

Enter the Adress Value and Location ID. Set protection to Off and Authentication to None.

Mail%20Sender%20Adapter

Mail Sender Adapter configuration

In the processing tab we can specify parameters of emails which will be re-sent to SAP Backend. It is possible to use dynamic parameters. You can get more information about topic here : https://help.sap.com/viewer/987273656c2f47d2aca4e0bfce26c594/Cloud/en-US/5705f2b41cca422e967511e3deb1beb4.html

Fill the parameter To with an e-mail address on the SAP backend where mails should be send.

Fill the parameters using expressions From : ${header.From}, Subject : ${header.Subject}, Mail Body : ${in.body} and check Add Message Attachements

Runtime%20Configuration

Runtime Configuration

To set an attribute to be dynamically filled by a message header attribute you need to allow headers in the Runtime Configuration tab.

Fill the Allowed Header(s) with From|Subject

Runtime%20Configuration

Runtime Configuration

These were necessary configuration steps for this scenario.

Conclusion

In this blogpost we described one of several possibilities how to use SAP Integration Suite and SAP Cloud Connector to integrate components from the the internet with components in your private network. There are many more integration scenarios you can do with SAP Integration Suite.

As this is my first blogpost on the SAP platform, fell free to provide me feedback, your thoughts of questions in the comment section. You can also follow me by clicking the green button above.

You can find community Q&A and post questions about Cloud Integration on this link.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.