I developed an app for our client that would process emails stored in Public Folders.
The Public Folders were hosted in an on-premise Exchange Server. The app ran on a Scheduled Task as Administrator.
The Administrator account had an Outlook Profile.
The app would login using rdoSession.Logon
and use rdoSession.Stores.FindExchangePublicFoldersStore
to access the Public Folders.
The exchange has now been migrated to Office 365 and the app now has to run on a VM in Azure.
The app no longer runs as Administrator but is run as NETWORK SERVICE. This is something I have no control over.
As this account doesn't have an Outlook Profile I want to be able to login to an Exchange account to access the Public Folders.
We use O365 so I can test the functionality locally. If I run the app in my account it works, as expected.
In an attempt to connect to Exchange without using the default profile I tried using:
rdoSession.LogonHostedExchangeMailbox("smtp.office365.com", "myAccount","myPassword")
This was fine and I was able to login. When I called rdoSession.Stores.FindExchangePublicFoldersStore
I get the error "Could not find the Public Folder store".
Is there a way to login to O365 Exchange with a specific account, without using the user's profile the app is run as, and access the Public Folders?