none
C# Update appointments in one sevice call using EWS managed API 2.0 RRS feed

  • Question

  • I'm setting a custom extended property for each existing appointment like that:

    var extendedPropertyDefinition = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.PublicStrings, "RateTheMeetingId24", MapiPropertyType.Integer);
    var propertySet = new PropertySet(PropertySet.FirstClassProperties) { extendedPropertyDefinition };
    appointment.Load(propertySet);
    appointment.SetExtendedProperty(extendedPropertyDefinition, meetingId);

    and than im updating appointment:

    appointment.Update(ConflictResolutionMode.AlwaysOverwrite);

    it works fine, but very slow, because Update() creates a call to exchange for every appointment. I would like to update meetings in one single call. I can make list of my appointments with setted custom property and than i would like to use something like that:

    UpdateAppointment(List<Appointment> appointmentsWithExtendedPropertySetted)
    {
        appointmentsWithExtendedPropertySetted.UpdateAll();
    }

    i have found a reference in MSDN about UpdateItems method: ExchangeService.UpdateItems method

    but i don't know how to use it. Any help or suggestions how to improve appointment update would be great, thanx

    Friday, July 19, 2013 4:59 PM

Answers

  • To use UpdateItems you just create a Generic List for Items you're updating (this is the base class that the other objects are derived from).

    List<Item> upUpdateBatch = new List<Item>();

    Make you change and add each Item to the Batch

    appointment.SetExtendedProperty(extendedPropertyDefinition, meetingId);
    upUpdateBatch.Add(appointment)

    Then call UpdateItems

    Service.UpdateItems(upUpdateBatch, Folder.Id, ConflictResolutionMode.AlwaysOverwrite, MessageDisposition.SaveOnly, SendInvitationsOrCancellationsMode.SendToNone);

    If you want better performance get rid of

    appointment.Load(propertySet);

    and use loadItemsFromProperties instead see
    http://blogs.msdn.com/b/exchangedev/archive/2010/03/16/loading-properties-for-multiple-items-with-one-call-to-exchange-web-services.aspx

    Cheers
    Glen

    • Marked as answer by erinev Monday, July 22, 2013 5:07 PM
    Monday, July 22, 2013 6:52 AM

All replies

  • To use UpdateItems you just create a Generic List for Items you're updating (this is the base class that the other objects are derived from).

    List<Item> upUpdateBatch = new List<Item>();

    Make you change and add each Item to the Batch

    appointment.SetExtendedProperty(extendedPropertyDefinition, meetingId);
    upUpdateBatch.Add(appointment)

    Then call UpdateItems

    Service.UpdateItems(upUpdateBatch, Folder.Id, ConflictResolutionMode.AlwaysOverwrite, MessageDisposition.SaveOnly, SendInvitationsOrCancellationsMode.SendToNone);

    If you want better performance get rid of

    appointment.Load(propertySet);

    and use loadItemsFromProperties instead see
    http://blogs.msdn.com/b/exchangedev/archive/2010/03/16/loading-properties-for-multiple-items-with-one-call-to-exchange-web-services.aspx

    Cheers
    Glen

    • Marked as answer by erinev Monday, July 22, 2013 5:07 PM
    Monday, July 22, 2013 6:52 AM
  • thanks, once more ! You are superb in exchange developement! :)
    Monday, July 22, 2013 5:09 PM