如何从单一事件掌握 Outlook 约会系列

问题描述 投票:0回答:2

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

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

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

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

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

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

outlook vsto outlook-object-model
2个回答
7
投票

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


-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/

© www.soinside.com 2019 - 2024. All rights reserved.