获得私人约会的主人

时间:2016-09-27 13:11:02

标签: c# office365 exchangewebservices

我无法使用C#的Exchange Web服务托管API查找如何获取一系列私人约会的主要事件。

当我在ExchangeService上使用FindAppointments检索约会列表时,我设法在搜索条件中获取事件。但是,当我尝试使用Appointment.BindToRecurringMaster获取定期主控约会时,其中id是私有事件的id,我得到错误"在商店中找不到指定的对象。,找不到项目。 "

我是否还有其他办法可以检索私人事件的主要事件?

在下面的示例中,我使用服务帐户进行身份验证,该帐户作为目标邮箱日历上的审阅者权限。

var exchangeService = new ExchangeService();
exchangeService.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
exchangeService.Credentials = new WebCredentials("service.user@organization.com", "password", "domain");

const string email = "other.user@organization.com";

// The following successfully retrieve all appointments including the private occurrence.
var appointments = exchangeService.FindAppointments(
    new FolderId(WellKnownFolderName.Calendar, new Mailbox(email)),
    new CalendarView(DateTime.UtcNow, DateTime.UtcNow.AddDays(1)));

const string id = "AAMkA..."; // Id of the private occurrence.
// The following fails saying "The specified object was not found in the store., Item not found."
var appointment = Appointment.BindToRecurringMaster(exchangeService, id);

感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

如果您没有通过委托操作查看私有项的委派访问权限,那么您描述的是私有项的预期行为。因此,您需要使用委托操作https://msdn.microsoft.com/en-us/library/office/dn641959(v=exchg.150).aspx在邮箱上授予服务帐户代理权限,并将ViewPrivateItems设置为true。或者将服务帐户FullAccess提供给邮箱或使用EWS模拟。

相关问题