获取私人约会的主事件

本文关键字:事件 约会 获取 | 更新日期: 2023-09-27 18:08:58

我在寻找如何使用c#的Exchange Web Service Managed 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);

获取私人约会的主事件

你描述的是私有项目的预期行为,如果你没有通过委托操作来访问私有项目。因此,您需要使用Delegate操作https://msdn.microsoft.com/en-us/library/office/dn641959(v=exchg.150).aspx为邮箱提供服务帐户委托权限,并将ViewPrivateItems设置为true。