Overflew
Overflew

Reputation: 8162

Outlook Redemption library - Accessing shared mailboxes / specific folders with a service account

I’m converting an existing piece of code using Redemption (an MS Exchange library) to operate under a service account. The issue I’m having is that I’m unable to look up mail folders as I previously was.

The first hurdle in moving to a service account was overcome by switching

_rdoSession.Logon() // <- Which uses the account’s MAPI profile, and throws an exception under a service account 

To:

_rdoSession.LogonExchangeMailbox("", "mailserver.example.com"); 

The problem comes with trying to access specific folders. Previously I was able to use:

_session.GetFolderFromPath("\\\\Mailbox - Example shared mailbox\\Inbox\\FolderOne"); 
_session.GetFolderFromPath("\\\\Mailbox - Example shared mailbox\\Inbox\\FolderTwo"); 

Under a service account, I can’t address shared mail accounts with that same syntax, as I get the error:

Could not open store "Mailbox – Example shared mailbox": Error in IMAPITable.FindRow: MAPI_E_NOT_FOUND 

Some Googling has shown the beginning step is to use:

_session.Stores.GetSharedMailbox("Example shared mailbox ")

I've verified this returns the correct shared mailbox object.

However - from there, there are no search methods. I can try my luck with building new code to navigate the folder structure from the .RootFolder property, but this seems like a hack.

How should I be accessing specific folders in a shared mailbox, run under a service account in Redemption?

Upvotes: 1

Views: 2596

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66255

You can use either

store = _session.Stores.GetSharedMailbox("Example shared mailbox ");

folder = store.IPMRootFolder.Folders.Item("Inbox").Folders.Item("FolderTwo");

or

store = _session.Stores.GetSharedMailbox("Example shared mailbox ");

folder = store.GetDefaultFolder(olFolderInbox).Folders.Item("FolderTwo");

Upvotes: 2

Related Questions