H
huangbo888
I am writting an Outlook Add-In and allowed user to perfrom calendar
sync with outlook. I have trouble in creatting and updating recurrence
exception appointment
in outlook, and I am using C# and Outlook Object Model.
I do some testing by the fllowing steps:
1. Manually create a recurrence appointment in outook and the
recurrence type is daily.
2. Manually create a recurrence exception appointment by changing an
occurence appointment subject.
3. Update recurrence exception appointment start time and date time
by Outlook object model and C#, sample code shows below:
AppointmentItem aptItem;
//Get the recurrence appointment item from Calendar folder
AppointmentItem aptItem = GetAnRecurrenceAppointmentItem();
RecurrencePattern pattern = aptItem.GetRecurrencePattern();
Microsoft.Office.Interop.Outlook.Exceptions exceptions =
pattern.Exceptions;
IEnumerator en = exceptions.GetEnumerator();
while (en.MoveNext())
{
Microsoft.Office.Interop.Outlook.Exception ex = en.Current
as Microsoft.Office.Interop.Outlook.Exception;
// Get recurrence appointment Item
AppointmentItem item = ex.AppointmentItem;
//Update start and end datetime by adding one day.
item.Start = new DateTime(item.Start.Year,
item.Start.Month, item.Start.Day + 1, 18, 0, 0);
item.End= new DateTime(item.End.Year, item.End.Month,
item.End.Day + 1, 19, 0, 0);
// it throws COM Exceptions when saving
item.Save();
break;
}
The above code throws COM exception says that the item can not be
saved.
Is there a approach to update an existing recurrence exception?
Thanks
Bo
sync with outlook. I have trouble in creatting and updating recurrence
exception appointment
in outlook, and I am using C# and Outlook Object Model.
I do some testing by the fllowing steps:
1. Manually create a recurrence appointment in outook and the
recurrence type is daily.
2. Manually create a recurrence exception appointment by changing an
occurence appointment subject.
3. Update recurrence exception appointment start time and date time
by Outlook object model and C#, sample code shows below:
AppointmentItem aptItem;
//Get the recurrence appointment item from Calendar folder
AppointmentItem aptItem = GetAnRecurrenceAppointmentItem();
RecurrencePattern pattern = aptItem.GetRecurrencePattern();
Microsoft.Office.Interop.Outlook.Exceptions exceptions =
pattern.Exceptions;
IEnumerator en = exceptions.GetEnumerator();
while (en.MoveNext())
{
Microsoft.Office.Interop.Outlook.Exception ex = en.Current
as Microsoft.Office.Interop.Outlook.Exception;
// Get recurrence appointment Item
AppointmentItem item = ex.AppointmentItem;
//Update start and end datetime by adding one day.
item.Start = new DateTime(item.Start.Year,
item.Start.Month, item.Start.Day + 1, 18, 0, 0);
item.End= new DateTime(item.End.Year, item.End.Month,
item.End.Day + 1, 19, 0, 0);
// it throws COM Exceptions when saving
item.Save();
break;
}
The above code throws COM exception says that the item can not be
saved.
Is there a approach to update an existing recurrence exception?
Thanks
Bo