如何从单个出现的Outlook约会系列主

时间:2013-02-07 12:20:19

标签: outlook vsto outlook-object-model

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

我尝试了以下(currentAppointment变量的类型为AppointmentItem)

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

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

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

我如何获得对olApptMaster的引用 - 即会议系列?

2 个答案:

答案 0 :(得分:5)

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

答案 1 :(得分:-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/