title: Identify item type when handling event in Exchange Web Services (EWS)
body: <p>I'm using streaming notifications with the EWS API. On the event handler I pick up the fact that an item has been modified, but my attempt to bind the modified item to an email message fails. The error message is specifically</p>
  
  <blockquote>
    <p>The item type returned by the service (Appointment) isn't compatible
    with the requested item type (EmailMessage).</p>
  </blockquote>
  
  <p>It seems like there must be a way to identify the item type before attempting to bind it, but I'm not sure what that is. The error occurs on attempting to <code>Bind</code>, so I can't simply check for null. I could resort to <code>try/catch</code>, but would prefer to do this properly if there is a better way?</p>
  
  <p>Summarised code:</p>
  
  <pre><code>void streamingConnection_OnNotificationEvent(object sender, NotificationEventArgs args)
  {
      foreach (NotificationEvent notificationEvent in args.Events)
      {
          ItemEvent itemEvent = notificationEvent as ItemEvent;
          if (itemEvent != null) HandleItemEvent(itemEvent);
      }
  }
  
  private void HandleItemEvent(ItemEvent itemEvent)
  {
      switch (itemEvent.EventType)
      {
          case EventType.Modified:
              EmailMessage modifiedMessage = EmailMessage.Bind(this.ExchangeService, itemEvent.ItemId);
              // error occurs on Bind if the item type is not an EmailMessage (eg, an Appointment)
              break;
      }
  }
  </code></pre>