如何按名称选择Outlook日历?

问题描述:

我想创建一个Outlook 2010插件,我可以选择一个日历并从中获取所有约会。如何按名称选择Outlook日历?

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

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

}