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("user@domain.com", 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!!!