本文介绍了Outlook 2010:如何获取所有约会(包括重复约会)的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图列出默认文件夹中的所有约会,像这样:

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 类型),然后可以对其进行迭代.

Try using the AppointmentItem.GetRecurrancePattern method (and RecurrencePattern type) off the appointment item, then you can iterate over them.

可以在此处找到:

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

这篇关于Outlook 2010:如何获取所有约会(包括重复约会)的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-06 14:36