Skip to Content
Oct 28, 2021 at 09:54 AM

Fetching Mail from an O365 mailbox with SAP PI

626 Views Last edit Oct 28, 2021 at 09:55 AM 2 rev

Hi all,

I am currently facing the problem of fetching mail from an O365 mailbox with the SAP PI SP20 to forward them to our internal backend SAP System.

My first idea was to use the mail adapter (mail sender), as it supports OAuth. My first hurdle, however, is communication into the cloud, as we only communicate on the Internet via our proxy, PI will not be placed in the DMZ or communicate anyway directly to the internet. I'm missing the proxy setting in the mail adapter and we also discussed whether the IMAP protocol could even be routed via our proxy.

The second idea is to use Microsoft's Mail API. But here I get stuck on the OAuth login, because the OAuth Flow we can use in SAP REST Sender (polling) is e.g. Client Credentials Grant. But O365 says: "OAuth access to IMAP, POP, SMTP AUTH protocols via OAuth2 client credentials grant flow is not supported."

On the other side O365 is using the "Authorization Code Grant", but this one is not supported by SAP. SAP says: "Please, note that other grant flows such as Authorization Code Grant and Implicit Grant, require end-user interaction and thus are not supported by the REST adapter!"

Currently I don't find a flow wich is accepted from both sides. Does any one have an idea to connect with REST Sender (polling) or Mail Sender Adapter to O365 to fetch mails with SAP PI? With CPI I find a nice blog, but we need the solution for PI.

During our search and as time went on, we came across Microsoft is working on a solution to add the Client Credential OAuth flow with its Microsoft feature id 70577 in December 2021.

I don't find in the Road Map Explorer a hint for the implementation of "Authorization Code Grant". Is SAP also taking a step forward and expanding the OAuth flows?

Thank you for your support and sharing your ideas.

BR Erik