2

打开约会实例时,我需要获取会议系列的主约会。

我已经尝试了以下(currentAppointment 变量是 AppointmentItem 类型)

DateTime sd = currentAppointment.GetRecurrencePattern().PatternStartDate;
DateTime st = currentAppointment.GetRecurrencePattern().StartTime;

AppointmentItem ai = currentAppointment.GetRecurrencePattern().GetOccurrence(sd+st.TimeOfDay);

然而,虽然这让我获得了该系列中的第一个约会,但它的 RecurrenceState 为 olApptOccurrence。

如何获得对 olApptMaster 的参考 - 即会议系列?

4

2 回答 2

6

AppointmentItem.Parent 将返回重复实例和异常的父 AppointmentItem。

于 2013-02-07T13:41:24.553 回答
-1

我有一种方法可以创建具有重复性的约会项目,但这与修改一个几乎相同,请告诉我这是否对您有帮助以及您是否需要更多信息。

这是C#中的代码

private void CreateNewRecurringAppointment(Outlook._Application OutlookApp) 
{ 
    Outlook.AppointmentItem appItem = null; 
    Outlook.RecurrencePattern pattern = null; 
    try 
    { 
        appItem = OutlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem) 
           as Outlook.AppointmentItem; 
        // create a recurrence 
        pattern = appItem.GetRecurrencePattern(); 
        pattern.RecurrenceType = Outlook.OlRecurrenceType.olRecursWeekly; 
        pattern.StartTime = DateTime.Parse("9:00:00 AM"); 
        pattern.EndTime = DateTime.Parse("10:00:00 AM"); 
        // we can specify the duration instead of using the EndTime property 
        // pattern.Duration = 60; 
        pattern.PatternStartDate = DateTime.Parse("11/11/2011"); 
        pattern.PatternEndDate = DateTime.Parse("12/25/2011"); 
        appItem.Subject = "Meeting with the Boss"; 
        appItem.Save(); 
        appItem.Display(true); 
    } 
    catch (Exception ex) 
    { 
        System.Windows.Forms.MessageBox.Show(ex.Message); 
    } 
    finally 
    { 
        if (pattern != null) 
           System.Runtime.InteropServices.Marshal.ReleaseComObject(pattern); 
        if (appItem != null) 
           System.Runtime.InteropServices.Marshal.ReleaseComObject(appItem); 
    } 
} 

来源: http: //www.add-in-express.com/creating-addins-blog/2011/11/07/outlook-recurring-appointment/

于 2013-02-07T12:29:02.463 回答