Can't save outlook appointment user properties
Hi All,
I am creating outlook appoinments from my windows application. I am adding one
user property for each appoinment so that I can retrieve that appoinment later with the unique property value I added.
Outlook.Application outlookApp = new Outlook.Application();
Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem)outlookApp.CreateItem(Out look.OlItemType.olAppointmentItem);
oAppointment.UserProperties.Add("Key", OlUserPropertyType.olText, true, Missing.Value);
oAppointment.UserProperties["Key"].Value = some randomly generated unique value.
oAppointment.Save();
After saving the appoinment, I am trying to retrieve the appoinment based on the user property I added.
Outlook.NameSpace oNS = outlookApp.GetNamespace("MAPI");
Outlook.MAPIFolder oCalendar = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFo lderCalendar);
Outlook.Items oItems = oCalendar.Items;
Outlook.AppointmentItem oAppt = (Outlook.AppointmentItem)oItems.Find("[Key]='the key value'");
But oAppt is coming as null because it is not able to search with that key value.But I am passing the exact value.
Can anyone provide any suggestion ?
Thanks
Panna
|