Tuesday, January 25, 2011

How to use recurrance Pattern using redemption using c#.net?

Its really very diffcult to read all the occurrances of a recurring meeting using any of the APIs available in the market. Sometimes if you will read through outlook apis then it will not give the correct time if user send the meeting from different time zone. Hope the below way some how help you to read the recurrence item.

        RDOSessionClass session = new RDOSessionClass();
                session.Logon("", "", false, false, null, false);
                RDOFolder folder = session.GetDefaultFolder(rdoDefaultFolders.olFolderCalendar);
                RDOItems items = folder.Items;
   foreach (object item in items)
                {
                    if (item is RDOAppointmentItem)
                    {
  RDOAppointmentItem rdoItem = item as RDOAppointmentItem;
  RDORecurrencePattern recPatt = rdoItem.GetRecurrencePattern();

                        int j = 1;
                        for (j = 1; j <= recPatt.Occurrences; j++)
                        {
//This loop will run for the no of ocuurance the recurring meeting contains.
                            RDOAppointmentItem rdoItem1 = null;
                            try
                            {
                                rdoItem1 = (RDOAppointmentItem)recPatt.GetOccurence(j);
                            
                            }
                            catch (System.Exception ex)
                            {
                                MessageBox.Show(ex.InnerException.ToString());
                            }
                        }
}
}

If there will be no end date is selected in the recurring Pattern then the Occurrences count returns 0. But the most important thing is that it also gives the perfect time incase if user changes the timezone.

No comments:

Post a Comment