none
Exchange WebServices API - How to Identify Deleted Items locally? RRS feed

  • Question

  • I'm writing a Syncronization operation with Exchange WebServices... Currently, only concerned with Updates and Deletes.  I've got Updates running fine, but I'm having an issue with Deletes...
    I've got my local items tied to the Exchange items via an extended property that stores the id of my local item...
    When I detect a delete, it's not returning the item (or it's extended properties), the `ItemChange.Item` is `null`, I assume because it no longer exists, but how would I know what to delete locally?  I thought about using the ItemId, but apparently that is not consistent...
          Folder calendar = Folder.Bind(service, new FolderId(WellKnownFolderName.Calendar, testEmail));
          ExtendedPropertyDefinition mapAppointmentId = new ExtendedPropertyDefinition(new Guid(EBI.Map.Appointment.ExchIdGuid), "mapAppointmentId", MapiPropertyType.Integer);
          
          ChangeCollection<ItemChange> icc = service.SyncFolderItems(calendar.Id, new PropertySet(mapAppointmentId), null, 512, SyncFolderItemsScope.NormalItems, syncState);
    
          syncState = icc.SyncState;
    
          foreach (ItemChange ic in icc)
          {
            int apptId = 0;
            switch(ic.ChangeType)
            {
              case ChangeType.Update:
    
                if (ic.Item.TryGetProperty<int>(mapAppointmentId, out apptId))
                {
                  Microsoft.Exchange.WebServices.Data.Appointment exchAppt = Microsoft.Exchange.WebServices.Data.Appointment.Bind(service, ic.ItemId);
                  EBI.Map.Appointment mapAppt = EBI.Map.Appointment.GetByID(apptId);
    
                  mapAppt.StartDateTime = exchAppt.Start;
                  mapAppt.EndDateTime = exchAppt.End;
    
                  // pass false to disable exchange sync on save
                  mapAppt.Save(false);
                }
                break;
              case ChangeType.Delete:
                // FAILS HERE: ic.Item is null since it's been deleted... makes sense, except how am I suppose to know what to delete in my system???
                if (ic.Item.TryGetProperty<int>(mapAppointmentId, out apptId))
                {
                  EBI.Map.Appointment mapAppt = EBI.Map.Appointment.GetByID(apptId);
                  mapAppt.AppointmentStatusTypeID = EBI.Map.Appointment.AppointmentStatus.Cancelled_Faculty;
    
                  // pass false to disable exchange sync on save
                  mapAppt.Save(false);
                }
                break;
            }
    




    • Edited by jondavidjohn Tuesday, January 10, 2012 8:51 PM
    • Moved by Min Zhu Friday, January 13, 2012 5:48 AM (From:.NET Base Class Library)
    Tuesday, January 10, 2012 6:37 PM

All replies

  • > I thought about using the ItemId, but apparently that is not consistent...

    From the description in the link provided, as long as the email is just deleted and not moving to other folder, it should be consistent.

    In fact, from the XML schema of possible response to "delete item" SyncFolderItems operation, only the ItemId will be returned.


    • Edited by cheong00 Wednesday, January 11, 2012 4:09 AM
    Wednesday, January 11, 2012 4:08 AM
  • Hi Jondavidjohn,

    I have moved this thread to Exchange Server Development forum for better support.

    Have a nice day!


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Friday, January 13, 2012 5:49 AM