Outlook 2010:如何获取所有约会的列表,包括重复发生(Outlook 2010: How to get a list of all appointments, including recurrences)
我试图列出默认文件夹中的所有约会,如下所示:
Outlook.MAPIFolder calendarFolder = outlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar); Outlook.Items outlookCalendarItems = calendarFolder.Items; outlookCalendarItems.IncludeRecurrences = true; List<Outlook.AppointmentItem> lst = new List<Outlook.AppointmentItem>(); foreach (Outlook.AppointmentItem item in outlookCalendarItems) { lst.Add(item); }这将列出所有约会,但定期约会除外 - 它仅列出第一个约会。 有没有办法将所有重复添加到此列表中?
I was trying to list all appointments in the default folder, like so:
Outlook.MAPIFolder calendarFolder = outlookApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar); Outlook.Items outlookCalendarItems = calendarFolder.Items; outlookCalendarItems.IncludeRecurrences = true; List<Outlook.AppointmentItem> lst = new List<Outlook.AppointmentItem>(); foreach (Outlook.AppointmentItem item in outlookCalendarItems) { lst.Add(item); }This lists all the appointments, except the recurring appointments - it only lists the first ocurrence. Is there a way to add all recurrences to this list?
最满意答案
尝试从约会项目中使用AppointmentItem.GetRecurrancePattern方法(和RecurrencePattern类型),然后您可以迭代它们。
可以在此处找到获得单个事件的示例:
private void CheckOccurrenceExample() { Outlook.AppointmentItem appt = Application.Session. GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar). Items.Find( "[Subject]='Recurring Appointment DaysOfWeekMask Example'") as Outlook.AppointmentItem; if (appt != null) { try { Outlook.RecurrencePattern pattern = appt.GetRecurrencePattern(); Outlook.AppointmentItem singleAppt = pattern.GetOccurrence(DateTime.Parse( "7/21/2006 2:00 PM")) as Outlook.AppointmentItem; if (singleAppt != null) { Debug.WriteLine("7/21/2006 2:00 PM occurrence found."); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } } }Try using the AppointmentItem.GetRecurrancePattern method (and RecurrencePattern type) off the appointment item, then you can iterate over them.
An example of getting a single occurrence can be found here:
private void CheckOccurrenceExample() { Outlook.AppointmentItem appt = Application.Session. GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar). Items.Find( "[Subject]='Recurring Appointment DaysOfWeekMask Example'") as Outlook.AppointmentItem; if (appt != null) { try { Outlook.RecurrencePattern pattern = appt.GetRecurrencePattern(); Outlook.AppointmentItem singleAppt = pattern.GetOccurrence(DateTime.Parse( "7/21/2006 2:00 PM")) as Outlook.AppointmentItem; if (singleAppt != null) { Debug.WriteLine("7/21/2006 2:00 PM occurrence found."); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } } }更多推荐
发布评论