[Exchange 2010][EWSMA][C# / PS]Timeout on DeleteItems operation RRS feed

  • Question

  • Hello fellow forum dwellers,

    I'm trying to get a calendar sync working (using PowerShell) and find myself faced with yet another problem: Calling the DeleteItems method (of the ExchangeService class) works for a time and then returns a timeout error.

    First of all, I got a function that returns the appointments
    Then I get the IDs and put them into an appropriate IEnumerator:

    $type = ("System.Collections.Generic.List"+'`'+"1") -as "Type"
    $type = $type.MakeGenericType("Microsoft.Exchange.WebServices.Data.ItemId" -as "Type")
    $ItemIDs = [Activator]::CreateInstance($type)
    # Add Appointment-ID
    foreach ($app in $appointments)

    next up I try to delete them:


    which given the amount of items involved (easily a few thousand or tens of thousands) times out (I really have no trouble at all understanding why).
    Sooooo ... I thought 'why not split the operation into acceptable bits?', which I then proceeded to do: Everytime the $itemIDs IEnumerator went beyond a set amount of items (I tried 100, 200 and 500, timeouts usually only occured somewhere around 900 using the first method), it would call the DeleteItems function and empty the IEnumerator. The result remained the same, the operation would terminate at about the usual amount of successful appointment-deletions, giving a time-out error. Completely new subsequent delete operations on items in teh same folder would fail as well. Later iterations on other calendars (using different impersonation) would work again until they too met their time-out threshold.

    In my despair I next tried building a new service object (not all that rational, I know it shouldn't do a thing anyway, but it was getting late and my brain - or what was left of it - was getting fairly heavy).

    Which led me to my conclusion that the DeleteItem Method appears to open a data stream of some kind and no matter how I split up the operations, it will simply pick up where it left. This means that, according to my limited understanding of how EWS works, I am likely looking for a way to do one of these two things:

    • Avoid the time-out mechanism
    • Close a connection and build a new one

    Any ideas on how to do this? Or am I heading completely into the wrong direction to begin with?

    Best regards and thanks for all and any help,

    P.s.: If this is a fairly basic problem that really shouldn't slow me down: Is there a proper introduction into EWS development out there somewhere that teaches a beginner all s/he needs to know? Cause I sure as hell am learning as I go (rather stumble, really).

    Wednesday, July 31, 2013 12:10 PM


All replies