1

我正在尝试创建一个 Outlook 2010 插件,我可以在其中选择一个日历并从中获取所有约会。

如何选择我自己创建的日历,而不是选择默认的 Office 日历?

4

1 回答 1

0
public static Items GetAppointmentsInRange(MAPIFolder mAPIFolder, DateTime startTime, DateTime endTime)
{
    string filter = string.Format("[Start] >= '{0}' AND [End] <= '{1}'", startTime.ToString("g"), endTime.ToString("g"));
    Items calItems = mAPIFolder.Items.Restrict(filter);             
    calItems.Sort("[Start]", Type.Missing);
    return calItems;
}

public static MAPIFolder GetTimeTrackingCalendar()
{
    MAPIFolder result = null;
    MAPIFolder calendars = (MAPIFolder)outlook.ActiveExplorer().Session.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
    for (int i = 1; i <= calendars.Folders.Count; i++)
    {
        if (calendars.Folders[i].Name != Constants.TIME_TRACKING_CALENDAR) continue;
        result = calendars.Folders[i];
        break;
    }
    return result;
}

public static Items FindDeveloperTimeForDates(DateTime beginDate, DateTime endDate)
{
    return OutlookApp.GetAppointmentsInRange(OutlookApp.GetTimeTrackingCalendar(), beginDate, endDate);

}
于 2014-04-02T12:21:40.263 回答