2013-02-07 42 views
2

当需要打开约会实例时,我需要获取会议系列的主约会。如何向Outlook预约系列主单次发生

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

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

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

不过,虽然这让我在该系列中的第一次约会,它有olApptOccurrence的RecurrenceState。

?我怎样才能到olApptMaster参考 - 即会议系列?

回答

5

AppointmentItem.Parent将返回母AppointmentItem的复发情况和异常。

+0

太棒了!谢谢。 MSFT文档对于父母的内容不太清楚 - 只是它是一个对象。非常感激。 – Marcin

+0

只要确保您检查RecurrenceState属性 - 对于常规(RecurrenceState ==(OlRecurrenceState.olApptNotRecurring)),Parent属性将返回eeh父级MAPIFolder。 –

+0

谢谢德米特里。你碰巧知道如何使该父对象可编辑?我问过的问题在这里:http://stackoverflow.com/questions/14788295/how-to-modify-the-appointmentitem-parent-object – Marcin

-1

我要创建与复发的约会项目的方法,但it's几乎相同,修改一个,告诉我,如果这能帮助你,如果你需要进一步的信息。

下面是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/

+0

谢谢,但这并不完全让我想去的地方。 scenari是我的用户在他们的calenda中开了一个系列会议。他们开了一个会议实例。然后我需要获得对该系列的参考,以便我可以在该系列上设置一个用户属性。 – Marcin