@@ -360,7 +360,7 @@ private void ProcessNotifications(object o)
360360 /// <param name="mailbox"></param>
361361 /// <param name="itemId"></param>
362362 /// <returns></returns>
363- EWS . ItemId ConvertId ( string mailbox , string ewsLegacyId )
363+ EWS . ItemId ? ConvertId ( string mailbox , string ewsLegacyId )
364364 {
365365 string legacyCacheKey = $ "{ mailbox } { ewsLegacyId } ";
366366 if ( _convertIdCache . ContainsKey ( legacyCacheKey ) )
@@ -420,12 +420,17 @@ void ProcessNotification(object e, EWS.StreamingSubscription Subscription)
420420 {
421421 _itemNotificationsReceived ++ ;
422422 if ( ! checkBoxShowItemEvents . Checked ) return ; // We're ignoring item events
423+ correctedId = ( e as EWS . ItemEvent ) . ItemId . UniqueId ;
423424 sEvent += "Item " + ( e as EWS . ItemEvent ) . EventType . ToString ( ) + ": " ;
424425 if ( IsLegacyId ( ( e as EWS . ItemEvent ) . ItemId . UniqueId ) )
425426 {
426427 // This is a legacy format ID, we need to convert it to the new format
427- correctedId = ConvertId ( sMailbox , ( e as EWS . ItemEvent ) . ItemId . UniqueId ) . UniqueId ;
428- sEvent += " (legacyId converted)" ;
428+ EWS . ItemId ? convertedId = ConvertId ( sMailbox , ( e as EWS . ItemEvent ) . ItemId . UniqueId ) ;
429+ if ( convertedId != null )
430+ {
431+ correctedId = convertedId . UniqueId ;
432+ sEvent += " (legacyId converted)" ;
433+ }
429434 if ( checkBoxQueryMore . Checked )
430435 _logger . Log ( sEvent ) ;
431436 }
@@ -434,12 +439,17 @@ void ProcessNotification(object e, EWS.StreamingSubscription Subscription)
434439 {
435440 _folderNotificationsReceived ++ ;
436441 if ( ! checkBoxShowFolderEvents . Checked ) return ; // We're ignoring folder events
442+ correctedId = ( e as EWS . FolderEvent ) . FolderId . UniqueId ;
437443 sEvent += "Folder " + ( e as EWS . FolderEvent ) . EventType . ToString ( ) + ": " ;
438444 if ( IsLegacyId ( ( e as EWS . FolderEvent ) . FolderId . UniqueId ) )
439445 {
440446 // This is a legacy format ID, we need to convert it to the new format
441- correctedId = ConvertId ( sMailbox , ( e as EWS . FolderEvent ) . FolderId . UniqueId ) . UniqueId ;
442- sEvent += " (legacyId converted)" ;
447+ EWS . ItemId ? convertedId = ConvertId ( sMailbox , ( e as EWS . FolderEvent ) . FolderId . UniqueId ) ;
448+ if ( convertedId != null )
449+ {
450+ correctedId = convertedId . UniqueId ;
451+ sEvent += " (legacyId converted)" ;
452+ }
443453 if ( checkBoxQueryMore . Checked )
444454 _logger . Log ( sEvent ) ;
445455 }
@@ -647,20 +657,20 @@ private string GetFolderName(EWS.FolderId folderId, EWS.ExchangeService service)
647657 {
648658 // Retrieve display name of the given folder
649659
650- string justFolderId = folderId . UniqueId ;
651- if ( IsLegacyId ( justFolderId ) )
660+ string folderUniqueId = folderId . UniqueId ;
661+ if ( IsLegacyId ( folderUniqueId ) )
652662 {
653663 // This is a legacy format ID, we need to convert it to the new format
654- EWS . ItemId convertedId = ConvertId ( service . ImpersonatedUserId . Id , justFolderId ) ;
664+ EWS . ItemId convertedId = ConvertId ( service . ImpersonatedUserId . Id , folderUniqueId ) ;
655665 if ( convertedId != null )
656- justFolderId = convertedId . UniqueId ;
666+ folderUniqueId = convertedId . UniqueId ;
657667 }
658668
659669 try
660670 {
661671 Utils . SetClientRequestId ( service ) ;
662672 Utils . CredentialHandler . ApplyCredentialsToExchangeService ( service ) ;
663- EWS . Folder oFolder = EWS . Folder . Bind ( service , new EWS . FolderId ( justFolderId ) , new EWS . PropertySet ( EWS . FolderSchema . DisplayName ) ) ;
673+ EWS . Folder oFolder = EWS . Folder . Bind ( service , new EWS . FolderId ( folderUniqueId ) , new EWS . PropertySet ( EWS . FolderSchema . DisplayName ) ) ;
664674 return oFolder . DisplayName ;
665675 }
666676 catch ( Exception ex )
0 commit comments