Board index » delphi » can read olAppointments from mailboxes but write is to PersonalCalendar

can read olAppointments from mailboxes but write is to PersonalCalendar

using D5, i can successfully read all appointments for each mailbox on
an Exchange server but when i try to write appointments using the same
CreateRecipient/GetSharedDefaultFolder, i am writing to the
PersonalFolder of the current user!

this is the iteration for each mailbox's ApptsFolder
  for j := 0 to lst1.items.count-1 do
  begin
    if localDB then
      ApptsFolder := NmSpace.GetDefaultFolder(olFolderCalendar) <--- for
standalone testing
    else begin
      myRecipient := NmSpace.CreateRecipient(lst1.items[j]);
      ApptsFolder :=
NmSpace.GetSharedDefaultFolder(myRecipient,olFolderCalendar);
    end;

this is the READ which works:

    for i := 1 to ApptsFolder.Items.Count do
    begin
      olAppt := (ApptsFolder.Items.Item(i) as AppointmentItem);
  ....

the WRITE though goes to the PersonalFolder:
  // first see if already there
  olAppt := nil;
  tempResult := ApptsFolder.items.Find(' [BillingInformation] =
'+QuotedStr(inttoStr(myRR)));
  if (tempResult <> nil) and (OleVariant(TempResult).Class = 26) then
    olAppt := TempResult as AppointmentItem;
  if olAppt = nil then // new
    olAppt := Outlook.CreateItem(olAppointmentItem) as AppointmentItem;

since i am ending up with duplicates in the Personal folder, i suspect i
am not 'hooking' to the ApptsFolder?
what am i doing wrong!??  should i use ApptsFolder.items.add?

thanks,

sher

 

Re:can read olAppointments from mailboxes but write is to PersonalCalendar


solved!

replace
    olAppt := Outlook.CreateItem(olAppointmentItem) as AppointmentItem;
with
      Idispatch(olAppt) := ApptsFolder.Items.Add(olAppointmentItem);

sher

Other Threads