exchangewebservices - 如何使用 FindItems() 获取在某个日期范围内开始的一次或多次重复出现的所有重复系列的经常性母版?

标签 exchangewebservices

背景:

我正在使用 Microsoft Exchange Web 服务托管 API 2.0。我正在尝试搜索日历文件夹并返回满足以下条件的所有约会项目:

  • 具有正常的敏感性
  • 具有“测试”类别
  • 在特定日期范围内开始

我得出的结论是,由于我需要过滤的不仅仅是我需要使用的日期 FindItems()而不是 FindAppoinments() .(如果有误,请纠正我。)FindItems() 的缺点是它只返回重复系列的主人,我需要自己分解事件。我正在毫无问题地分解大师,但是在我的测试中遇到了 FindItems() 搜索重复的方式的问题。如果整个系列在我的搜索范围内的某个时间开始,它似乎只会返回循环系列的主人。因此,如果有人为下一年每天设置了一个循环系列,而我在下个月搜索日历,则 FindItems() 不会给出任何迹象表明在该范围内发生了一个循环系列。

TLDR:

给定一个包含循环系列的日历,该系列的每日频率从 2014 年 1 月 1 日开始到 2014 年 1 月 30 日结束。如何使用过滤日期范围为 1/10/2014 - 1/20/2014 的 FindItems() 返回该系列的循环主数据?

我的代码

// A search collection that contains all of the search conditions.
List<SearchFilter> masterSearchFilterCollection = new List<SearchFilter>();
masterSearchFilterCollection.Add(new SearchFilter.IsEqualTo(ItemSchema.ItemClass, "IPM.Appointment"));

masterSearchFilterCollection.Add(new SearchFilter.IsEqualTo(AppointmentSchema.Sensitivity, Sensitivity.Normal)); //No Private items
//masterSearchFilterCollection.Add(new SearchFilter.ContainsSubstring(AppointmentSchema.Categories, "Test"));

List<SearchFilter> dateRangeSearchFilterCollection = new List<SearchFilter>();
dateRangeSearchFilterCollection.Add(new SearchFilter.IsGreaterThanOrEqualTo(AppointmentSchema.Start, searchStartDateTime));
dateRangeSearchFilterCollection.Add(new SearchFilter.IsLessThanOrEqualTo(AppointmentSchema.Start, searchEndDateTime));
masterSearchFilterCollection.Add(new SearchFilter.SearchFilterCollection(LogicalOperator.And, dateRangeSearchFilterCollection));

SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, masterSearchFilterCollection);

ItemView view = new ItemView(pageSize, initialOffset);
view.PropertySet = GetPrimaryProperties();
FindItemsResults<Item> results = Service.FindItems(Folder, searchFilter, view);

foreach(Appointment item in results)
{
   if (item.AppointmentType == AppointmentType.RecurringMaster)
   {
      // Calendar item is a recurring master item for a recurring series.
      // Loop through all occurrences of the master here
   }
   else
   {
      // Calendar item is not part of a recurring series.
   }
}

最佳答案

约翰,

为了找到您的定期主约会,您需要使用 FindAppointments() 方法。在此方法中指定开始和结束日期将允许您查看跨越该日期范围的任何定期约会。然后,您可以通过检查这些约会的敏感度和类别属性来过滤您的约会

找到符合条件的约会后,检查 AppointmentType 属性以确定下一步要做什么。如果是 Occurrence 或 Exception,那么您可以使用 Appointment.BindToRecurringMaster() 方法访问您的循环主控。这是一个例子:

switch (calendarItem.AppointmentType)
{
    case AppointmentType.RecurringMaster:
       // Nothing to do here since you are already on the recurring master
       break;

    case AppointmentType.Single:
       // This is not a recurring series
       break;

    case AppointmentType.Occurrence:
       // We need to get to the recurring master
       Appointment recurringMaster = Appointment.BindToRecurringMaster(service, calendarItem.Id);
       break;

    case AppointmentType.Exception:
       // We need to get to the recurring master
       Appointment recurringMaster = Appointment.BindToRecurringMaster(service, calendarItem.Id);
       break;

}

现在您已经有了对循环主控的引用,您可以像以前一样遍历这些事件。

希望对您有所帮助。

关于exchangewebservices - 如何使用 FindItems() 获取在某个日期范围内开始的一次或多次重复出现的所有重复系列的经常性母版?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22464784/

相关文章:

c# - EWS 获得提醒 <= 当前时间的约会

c# - Exchange Web 服务 2010 入门

android - 在 Android 中通过 HTTPS 使用 SOAP+XML 请求 Exchange Web 服务 2007/2010

java - EWS-Java-API - EmailMessage.send 到 java.lang.NullPointerException : format == null

c# - Exchange Web 服务 - 从服务收到的响应不包含有效的 XML

c# - 底层连接已关闭: An unexpected error occurred on a send on

exchangewebservices - 使用 EWS 获取原始电子邮件文本(标题、正文和编码附件)

c# - 没有用户名/密码的 Exchange Web 服务授权

c# - Exchange Web Services 2010/自动完成或建议的联系人

python - 如何使用 Python 通过 Microsoft Exchange Web 服务 API 发送电子邮件