Cloud9
Cloud9

Reputation: 11

Search Mailboxes in an Outlook Account using ExchangeService C#

I have an Office Outlook account with many additional Mailboxes. Programmatically we need to read/download emails from each of those Mailboxes. I tried the below code

        service.Url = new Uri(url);
        service.Credentials = new WebCredentials("[email protected]", pName);
GetSearchableMailboxesResponse resp = service.GetSearchableMailboxes("quick", false);

        foreach(SearchableMailbox mailbox in resp.SearchableMailboxes)
        {
            Console.WriteLine("DisplayName:" + mailbox.DisplayName);
            Console.WriteLine("PrimarySmtpAddress:" + mailbox.SmtpAddress);
            Console.WriteLine("ReferenceId:" + mailbox.ReferenceId);
            Console.WriteLine("--------------------------------------------");
        }

It shows an error at the line:

GetSearchableMailboxesResponse resp = service.GetSearchableMailboxes("quick", false);

Error:

The caller has not assigned any of the RBAC roles requested in the management role header.

It looks like some role/access permission need to be set to allow access to mailboxes. Any help appreciated!!!

Upvotes: 1

Views: 2301

Answers (1)

Glen Scales
Glen Scales

Reputation: 22032

The eDiscovery Operations in EWS requires that the calling user has the Discovery Management RBAC see https://technet.microsoft.com/en-us/library/dd298059(v=exchg.160).aspx

Upvotes: 2

Related Questions