我有一个Office Outlook帐户,其中包含许多其他邮箱。我们需要以编程方式从每个邮箱中读取/下载电子邮件。我尝试了下面的代码
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("--------------------------------------------");
}
它在行显示错误:
GetSearchableMailboxesResponse resp = service.GetSearchableMailboxes("quick", false);
错误:
The caller has not assigned any of the RBAC roles requested in the management role header.
看起来需要设置一些角色/访问权限才能允许访问邮箱。 任何帮助表示赞赏!!!
答案 0 :(得分:2)
EWS中的电子数据展示操作要求主叫用户具有发现管理RBAC,请参阅https://technet.microsoft.com/en-us/library/dd298059(v=exchg.160).aspx