LastModificationTime is not updated

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.
 
K

Ken Slovak - [MVP - Outlook]

Try releasing all references to your newly created appointment after
retrieving the EntryID and then getting the item as a new object using
NameSpace.GetItemFromID. Outlook caches items until you release all
references to them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top