Outlook 2010:如何获取所有约会的列表,包括重复发生(Outlook 2010: How to get a list of all appointments, including recur

编程入门 行业动态 更新时间:2024-10-18 03:26:09
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); } } }

更多推荐

本文发布于:2023-08-06 03:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1444493.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发生   列表   Outlook   recurrences   including

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!