I am attempting to integrate our program with outlook and my test code below (sort of works) but have the following issues.
In testing I was able to add the appointment. Then manually moved the appointment to another date/time and re-ran the test program and it moved back (as expected). But...
when an item is deleted the code below is still able to locate the item (somehow!). I even manually removed the item from the Deleted Items folder in Outlook.
as a result,since it 'found' the appointment, it then attempts to update it, resulting in a AV as well. I suspect there is something wrong in my use of the find function, but what I am trying to do is to use userProperties to add something from our system to add into the appointment item in outlook and update if needed. But also needs to be able to handle the case where a user might manually delete item from calendar as well.
Any assistance would be greatly appreciated.
folder := ns.GetDefaultFolder(olFolderCalendar);
if not VarIsNull(folder) and not VarIsEmpty(folder) then
begin
try
appointment := folder.Items.Find('[MyRecProperty2]=' + quotedStr(1001));
entryFound := true;
except
end;
if (not entryFound) or
(varType(Appointment)=varNull) or
(varType(Appointment)=varEmpty) then
begin
appointment := folder.Items.Add(olAppointmentItem);
prop := appointment.UserProperties.Add('MyRecProperty2',olText,True);
prop.Value := '1001';
NewAppointment(appointment);
end
else
begin
showmessage('updating appointment!');
FillAppointment(appointment, false);
end;
showmessage('saving appointment!');
appointment.Save;
//showmessage('display appointment!');
//appointment.Display(true);