Search code examples
c#exchangewebservicesexchange-server-2013

Exchange 2013 get uniqueId of WellKnownFolderName


This might be stupid but i have been looking for this for a long time now and i still don't have any idea on how to do it. my problem is that i got a folderId(which has no name but just the UniqueId) coming from an event and i want to know if this forder is the DeletedItems one.

when i call the methods :

new FolderId(WellKnownFolderName.DeletedItems)

or

new FolderId(WellKnownFolderName.DeletedItems, mailBox)

i just get a FolderId which name is set but UniqueId is still null, therefore i can't compare UniqueId, the method Equals also fail... Btw, i working on exchange server 2013 with an impersonatedUser.

Edit : I feel even more stupid as i finally found out how easy it was : *

var folder = Folder.Bind(ewsInstance, WellKnownFolderName.DeletedItems);
if (Equals(event.ParentFolderId.UniqueId, folder.Id.UniqueId))

Solution

  • Finaly found the answer :

    var folder = Folder.Bind(ewsInstance, WellKnownFolderName.DeletedItems);
    if (Equals(event.ParentFolderId.UniqueId, folder.Id.UniqueId))//...