L
liuhengyi
Hi,
I have a program that will create an Outlook appointment object and
then get the appointment's LastModificationTime. However the
LastModificationTime is not updated if the newly created appointment is
modified in the Outlook. The following is my code:
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
oNS.Logon(oNS.CurrentUser.Name, "", true, true);
// Create an appointment
Outlook.AppointmentItem newitem =
(Outlook.AppointmentItem)oApp.CreateItem(OlItemType.olAppointmentItem);
// set appointment's properties
newitem.Save();
// Pause the program and open the appointment in Outlook.
// Modify the appointment body and then save and close it.
// Continue the program and show the LastModificationTime field
Outlook.MAPIFolder oCalendar =
oNS.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
Outlook.Items olApptItems = oCalendar.Items;
Outlook.AppointmentItem oAppt = (Outlook.AppointmentItem)
olApptItems.GetFirst();
Console.WriteLine(oAppt.LastModificationTime);
The problem is that it still shows the time when the appointment was
first created, instead of the time when it was modified in Outlook. It
looks like the LastModificationTime is cached. I tried to Logoff and
Logon again and it doesn't help. Is there a way to force it to
refresh the field? Thanks.
I have a program that will create an Outlook appointment object and
then get the appointment's LastModificationTime. However the
LastModificationTime is not updated if the newly created appointment is
modified in the Outlook. The following is my code:
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
oNS.Logon(oNS.CurrentUser.Name, "", true, true);
// Create an appointment
Outlook.AppointmentItem newitem =
(Outlook.AppointmentItem)oApp.CreateItem(OlItemType.olAppointmentItem);
// set appointment's properties
newitem.Save();
// Pause the program and open the appointment in Outlook.
// Modify the appointment body and then save and close it.
// Continue the program and show the LastModificationTime field
Outlook.MAPIFolder oCalendar =
oNS.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
Outlook.Items olApptItems = oCalendar.Items;
Outlook.AppointmentItem oAppt = (Outlook.AppointmentItem)
olApptItems.GetFirst();
Console.WriteLine(oAppt.LastModificationTime);
The problem is that it still shows the time when the appointment was
first created, instead of the time when it was modified in Outlook. It
looks like the LastModificationTime is cached. I tried to Logoff and
Logon again and it doesn't help. Is there a way to force it to
refresh the field? Thanks.