Outlook 2010:如何获取所有约会的列表,包括重复约会

发布于 2024-11-16 08:38:00 字数 507 浏览 5 评论 0原文

我试图列出默认文件夹中的所有约会,如下所示:

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三寸金莲 2024-11-23 08:38:00

尝试使用 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);
        }
    }
}
月野兔 2024-11-23 08:38:00

如果按开始时间排序,则可以使用 IncludeRecurrences 属性获取所有约会项目。需要注意的是,如果您有没有结束的重复约会,您将陷入无限循环,因此请务必测试结束日期。

请参阅:https://msdn.microsoft.com/ en-us/library/bb220097(v=office.12).aspx

If you sort by start time, you can then use the IncludeRecurrences property to get all appointment items. One word of caution - if you have recurring appointments that don't have an end, you'll get an infinite loop - so be sure and test for an end date.

See: https://msdn.microsoft.com/en-us/library/bb220097(v=office.12).aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文