2

I am using the Exchange Web Services API with a streaming connection to pick up changes to my calendar.

If I go to my calendar and delete an event, the new notification event method kicks off:

private void OnNewEvent(object sender, NotificationEventArgs args) {
    var ids = from e in args.Events.OfType<ItemEvent>()
              select e.ItemId;

    //This results in an error code
    var response = args.Subscription.Service.BindToItems(ids, new PropertySet(BasePropertySet.FirstClassProperties));
}

However, I am unable to find the event that was deleted. I want to be able to fetch the event details (e.g. name, scheduled time, etc). Is there any way to get the event when it's been deleted or is the only piece of information that I can retrieve the id?

Justin Helgerson
  • 24,900
  • 17
  • 97
  • 124

2 Answers2

0

as written here Pull notifications for EWS deletion-related mailbox events in Exchange for exchange 2010, the event is of type "DeletedEvent". As the operation Item.Bind(OldItemId) would fail since the item is deleted. The only infos you can have now is OldFolderId and OldItemId from the event. Except if you have the corresponding information (OutlookUniqueId=>AllInfos) in some database for example, you won't be able to get it.

gilles emmanuel
  • 221
  • 3
  • 16
0

Streaming Notifications do not generate a Delete event. When an Item is Deleted, it is Moved to the Deleted Items Folder.

Therefore, you need to check for the EventType.Moved notification.

private void OnNewEvent(object sender, NotificationEventArgs args) {
    foreach (var notification in args.Events.OfType<ItemEvent>())
    {
        if (notification.EventType == EventType.Moved)
            var item = Item.Bind(service, notification.ItemId);
    }
}
MadDev
  • 1,130
  • 1
  • 13
  • 29