交换 EWS、日历 FindItems 与 FindAppointments?
Exchange EWS, Calendar FindItems vs FindAppointments?
我按照本指南检索了通过 Outlook 在 Exchange 中召开的会议; https://msdn.microsoft.com/en-us/library/office/dn495614(v=exchg.150).aspx
一切正常,无一例外,但 return 没有任何结果。然后我尝试了 FindItems 而不是 FindAppointments,这 return 我的结果。为什么 FindAppointments 不 return 会议?
我正在 Outlook Online 中创建测试约会。通过单击“菜单”>“日历”>“新建”,我完成了事件的详细信息,然后在保存之前添加了与会者。这些是由 FindItems() 编辑的 return,但似乎没有 属性 来检索位置和参加者列表?如果数据是 returned,FindAppointments 会给我所需的属性。我之前在计算机上安装了 Outlook,在创建会议时特别提到 'Meeting' 这个词,这似乎是日历项目。我不确定有什么区别?
我的最终目标是当用户通过 Outlook 安排会议时,我将有一个应用程序来检索这些会议的详细信息。与会者名单和地点。
非常感谢任何指点!
我们需要将所需项目列表添加到 属性 集合,在给定的示例中,属性 集合受到限制。
在 属性 代码中
// Limit the properties returned to the appointment's subject, start time, and end time.
cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);
而不是上面使用下面的 属性 设置,
cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Location, AppointmentSchema.RequiredAttendees);
或者最适合初步学习的是
// Limit the properties returned to the appointment's subject, start time, and end time.
cView.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
设法从这个 thread
中找到解决方案
代码可以进行整理,但它正确地取消了约会并允许我获取我需要的数据。
FindItemsResults<Item> result = service.FindItems(WellKnownFolderName.Calendar, new CalendarView(DateTime.Now, DateTime.Now.AddDays(7)));
foreach(Item item in result.Items)
{
ServiceResponseCollection<GetItemResponse> itemResponseCollection = service.BindToItems(new[] { new ItemId(item.Id.UniqueId) }, new PropertySet(BasePropertySet.FirstClassProperties));
foreach(GetItemResponse itemResponse in itemResponseCollection)
{
Appointment appointment = (Appointment)itemResponse.Item;
Console.WriteLine("Subject: " + appointment.Subject);
Console.WriteLine("Location: " + appointment.Location);
Console.WriteLine("AppointmentType: " + appointment.AppointmentType.ToString());
Console.WriteLine("Body: " + appointment.Body);
Console.WriteLine("End: " + appointment.End.ToString());
Console.WriteLine("UniqueId: " + appointment.Id.UniqueId);
Console.WriteLine("Start: " + appointment.Start.ToString());
Console.WriteLine("When: " + appointment.When);
Console.WriteLine("Required Attendees: ");
foreach (var attendee in appointment.RequiredAttendees)
{
Console.WriteLine(attendee.Name);
}
}
我按照本指南检索了通过 Outlook 在 Exchange 中召开的会议; https://msdn.microsoft.com/en-us/library/office/dn495614(v=exchg.150).aspx
一切正常,无一例外,但 return 没有任何结果。然后我尝试了 FindItems 而不是 FindAppointments,这 return 我的结果。为什么 FindAppointments 不 return 会议?
我正在 Outlook Online 中创建测试约会。通过单击“菜单”>“日历”>“新建”,我完成了事件的详细信息,然后在保存之前添加了与会者。这些是由 FindItems() 编辑的 return,但似乎没有 属性 来检索位置和参加者列表?如果数据是 returned,FindAppointments 会给我所需的属性。我之前在计算机上安装了 Outlook,在创建会议时特别提到 'Meeting' 这个词,这似乎是日历项目。我不确定有什么区别?
我的最终目标是当用户通过 Outlook 安排会议时,我将有一个应用程序来检索这些会议的详细信息。与会者名单和地点。
非常感谢任何指点!
我们需要将所需项目列表添加到 属性 集合,在给定的示例中,属性 集合受到限制。 在 属性 代码中
// Limit the properties returned to the appointment's subject, start time, and end time.
cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End);
而不是上面使用下面的 属性 设置,
cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.Location, AppointmentSchema.RequiredAttendees);
或者最适合初步学习的是
// Limit the properties returned to the appointment's subject, start time, and end time.
cView.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);
设法从这个 thread
中找到解决方案代码可以进行整理,但它正确地取消了约会并允许我获取我需要的数据。
FindItemsResults<Item> result = service.FindItems(WellKnownFolderName.Calendar, new CalendarView(DateTime.Now, DateTime.Now.AddDays(7)));
foreach(Item item in result.Items)
{
ServiceResponseCollection<GetItemResponse> itemResponseCollection = service.BindToItems(new[] { new ItemId(item.Id.UniqueId) }, new PropertySet(BasePropertySet.FirstClassProperties));
foreach(GetItemResponse itemResponse in itemResponseCollection)
{
Appointment appointment = (Appointment)itemResponse.Item;
Console.WriteLine("Subject: " + appointment.Subject);
Console.WriteLine("Location: " + appointment.Location);
Console.WriteLine("AppointmentType: " + appointment.AppointmentType.ToString());
Console.WriteLine("Body: " + appointment.Body);
Console.WriteLine("End: " + appointment.End.ToString());
Console.WriteLine("UniqueId: " + appointment.Id.UniqueId);
Console.WriteLine("Start: " + appointment.Start.ToString());
Console.WriteLine("When: " + appointment.When);
Console.WriteLine("Required Attendees: ");
foreach (var attendee in appointment.RequiredAttendees)
{
Console.WriteLine(attendee.Name);
}
}