2

I need to get the master appointment of the meeting series, when an appointment instance is opened.

I have tried the following (currentAppointment variable is of type AppointmentItem)

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

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

However, while this gets me the first appointment in the series, it has a RecurrenceState of olApptOccurrence.

How can I get a reference to the olApptMaster - ie the meeting series?

Reg Edit
  • 6,719
  • 1
  • 35
  • 46
Marcin
  • 1,889
  • 2
  • 16
  • 20

2 Answers2

6

AppointmentItem.Parent will return the parent AppointmentItem for the recurrence instances and exceptions.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • Brilliant! Thanks. The MSFT documentation is not very clear on what the parent is - just that it's an object. Much appreciated. – Marcin Feb 07 '13 at 14:19
  • Just make sure you check the RecurrenceState property - for regular (RecurrenceState == (OlRecurrenceState.olApptNotRecurring)), Parent property will return eeh parent MAPIFolder. – Dmitry Streblechenko Feb 07 '13 at 16:27
  • Thanks Dmitry. Do you happen to know how to make that parent object editable? I've asked the question here: http://stackoverflow.com/questions/14788295/how-to-modify-the-appointmentitem-parent-object – Marcin Feb 09 '13 at 13:43
  • The Parent *is* editable unless you have read-only access t othat folder. – Dmitry Streblechenko Feb 10 '13 at 17:48
  • @DmitryStreblechenko, as the doc is not clear, is there any difference between `item.IsRecurring` and `RecurrenceState != OlRecurrenceState.olApptNotRecurring` ? – Hamlet Hakobyan Jan 27 '16 at 13:22
  • Yes, IsRecurring is a Boolean. OlRecurrenceState is more granular (olApptNotRecurring, olApptMaster, olApptOccurrence, olApptException). – Dmitry Streblechenko Jan 27 '16 at 17:26
-1

I have a method to create an appointment item with recurrence, but it´s almost the same as modifying one, tell me if that helps you and if you need further information.

Here is the code in 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); 
    } 
} 

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

rdarioduarte
  • 1,929
  • 2
  • 21
  • 29
  • thanks, but that doesn't quite get me where I want to be. The scenari is my user has a meeting series in their calenda. They open a meeting instance. I need to then get a reference to the series, so that I can set a userproperty on the series. – Marcin Feb 07 '13 at 13:34