交换EWS,日历FindItems与FindAppointments?

时间:2018-05-23 10:05:59

标签: c# outlook exchange-server exchangewebservices

我按照本指南检索通过Outlook制作的Exchange会议; https://msdn.microsoft.com/en-us/library/office/dn495614(v=exchg.150).aspx

一切运行良好,没有例外,但它不会返回任何结果。然后我尝试使用FindItems而不是FindAppointments,这确实返回了我的结果。为什么FindAppointments不会返回会议?

我在Outlook中在线创建测试约会。点击菜单>日历>新的,我完成了活动的详细信息,然后在保存之前添加与会者。这些是由FindItems()返回的,但似乎不是检索位置和参加者列表的属性?如果返回数据,FindAppointments将为我提供所需的属性。我之前在计算机上安装了Outlook,其中创建会议专门提到“会议”这个词。这似乎是日历项目。我不确定区别是什么?

我的最终目标是当用户通过Outlook安排会议时,我会有一个应用程序来检索这些会议的详细信息。与会者名单和地点。

非常感谢任何指示!

2 个答案:

答案 0 :(得分:0)

我们需要向属性集添加所需项的列表,在给定的示例中,属性集是受限制的。 在属性代码中

// 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);

答案 1 :(得分:0)

需要找到从此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);
                    }
                }