[E2010] [EWSMA] [C#] [Windows]: Get Deleted Item with StreamingNotification RRS feed

  • Frage

  • Hello,

    I have to deploy a program which can connect to an Exchange Server 2010. It subscribes to the created, modified and deleted event, but if an element is deleted, it doesn't tell me which element it was. So I would have to sync the contacts or the calendar folder to know which element has been deleted.

    Here's my code:

    foreach (var item in mapping.Keys)
    	ExchangeService ser = new ExchangeService(ExchangeVersion.Exchange2010_SP1, TimeZoneInfo.FindSystemTimeZoneById("W. Europe Standard Time"));
    	ser.Credentials = new WebCredentials(EWSUsername, EWSPassword, EWSDomain);
    	ser.Url = EWSHost;
    	ser.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, item);
    	StreamingSubscription subscription = ser.SubscribeToStreamingNotifications(
    		new FolderId[] { WellKnownFolderName.Contacts, WellKnownFolderName.Calendar },
    	services.Add(item, ser);

    The loop is necessary, because I'm watching more than one user (In the end about 100 to 1000).

    static void connection_OnNotificationEvent(object sender, NotificationEventArgs args)
    	foreach (NotificationEvent notificationEvent in args.Events)
    	// When I get notificationEvent.Deleted here, it's only a folder event
    	// There's no ItemId

    A workaround I got from Jageen (StackOverflow) is to catch the moved event, but that's not working if you press Shift and Delete to delete the element(s) immediately.

    Isn't there any other way to get information about an deleted element?

    • Bearbeitet Sprigtail Donnerstag, 18. Juli 2013 05:33 Added Tags
    Mittwoch, 17. Juli 2013 06:40