none
[EWS 2010][C#] How to determine appointment recurrence type RRS feed

  • Question

  • I use this code to get the detail of appointment, but I can't check this appointment is kind of daily, weekly, monthly or yearly recurrence.

    DateTime startDate = new DateTime(2012, 5, 1);
    DateTime endDate = new DateTime(2012, 5, 31);
    CalendarView calView = new CalendarView(startDate, endDate);
    calView.PropertySet = new PropertySet(BasePropertySet.IdOnly, AppointmentSchema.Subject, AppointmentSchema.Recurrence, AppointmentSchema.AppointmentReplyTime,
    AppointmentSchema.Start, AppointmentSchema.End, AppointmentSchema.IsRecurring, AppointmentSchema.AppointmentType, AppointmentSchema.Id);
    
    FindItemsResults<Appointment> findResults = service.FindAppointments(WellKnownFolderName.Calendar, calView);
      foreach (Appointment appt in findResults.Items)
      { 
         if (appt.AppointmentType == AppointmentType.Occurrence)
         {
                            Console.WriteLine(appt.Subject);
                            Console.WriteLine(appt.Id);
                            Console.WriteLine(appt.Start);
                            Console.WriteLine(appt.End);
                            Console.WriteLine();
                            Console.WriteLine("\n\n -------------");
           }
    }

    Please tell me how can I do that. Thanks in advance!

    Monday, May 21, 2012 4:28 AM

Answers

  • You need to bind to the MasterInstance to get this information (this is where the recurrence pattern is held and why you only see null on a Instance) eg you should be able to do something like

                FindItemsResults<Appointment> findResults = service.FindAppointments(WellKnownFolderName.Calendar, calendarView);
                
                foreach (Appointment item in findResults.Items)
                {
                    if (item.IsRecurring == true)
                    {
                        Appointment master = Appointment.BindToRecurringMaster(service, item.Id);
    
                        if (master.Recurrence is Recurrence.DailyPattern)
                        {
    
                        }
                    }
    Cheers
    Glen
    • Marked as answer by shinkt Tuesday, May 22, 2012 2:19 AM
    Monday, May 21, 2012 6:23 AM

All replies

  • You need to bind to the MasterInstance to get this information (this is where the recurrence pattern is held and why you only see null on a Instance) eg you should be able to do something like

                FindItemsResults<Appointment> findResults = service.FindAppointments(WellKnownFolderName.Calendar, calendarView);
                
                foreach (Appointment item in findResults.Items)
                {
                    if (item.IsRecurring == true)
                    {
                        Appointment master = Appointment.BindToRecurringMaster(service, item.Id);
    
                        if (master.Recurrence is Recurrence.DailyPattern)
                        {
    
                        }
                    }
    Cheers
    Glen
    • Marked as answer by shinkt Tuesday, May 22, 2012 2:19 AM
    Monday, May 21, 2012 6:23 AM
  • Thanks, that is the thing I need
    Tuesday, May 22, 2012 2:19 AM