【问题标题】:Exchange EWS, Calendar FindItems vs FindAppointments?Exchange EWS、日历 FindItems 与 FindAppointments?
【发布时间】:2018-05-23 10:05:58
【问题描述】:

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

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

我正在 Outlook Online 中创建测试约会。通过单击菜单 > 日历 > 新建,我完成了活动的详细信息,然后在保存之前添加了与会者。这些由 FindItems() 返回,但似乎没有用于检索位置和参加者列表的属性?如果返回数据,FindAppointments 会给我所需的属性。我之前在计算机上安装了 Outlook,其中创建会议特别提到了“会议”一词,这似乎是日历项目。不知道有什么区别?

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

非常感谢您的任何指点!

【问题讨论】:

    标签: c# outlook exchange-server exchangewebservices


    【解决方案1】:

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

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

    【讨论】:

    • 您好,感谢 Sivakrishna,不幸的是,这并不能解决我遇到的问题。无论我使用什么 PropertySet,FindAppointments()(在教程示例中使用)都不会返回任何行。当我改用 FindItems() 时,它会找到数据,但此方法采用 ItemView 参数,而不是 FindAppointments() 使用的 CalendarView 参数。当我在 Outlook 日历上创建一个条目时,我希望 FindAppointments() 可以访问它以及与会者列表和位置。只有 FindItem() 可以找到数据,但它没有与会者列表或位置。
    【解决方案2】:

    设法从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);
                        }
                    }
    

    【讨论】:

      猜你喜欢
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 2011-11-16
      • 2021-07-15
      • 1970-01-01
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多