public override void EnumerationFinished() { if (_folder != null) { _folder.Dispose(); } _tracer.Trace("EnumerationFinished"); }
[Test] public void OpenTasksFolderTest() { IEMsgStore msgStore = OutlookSession.GetDefaultMsgStore(); Assert.IsNotNull(msgStore); IEFolder folder = msgStore.OpenTasksFolder(); Assert.IsNotNull(folder); folder.Dispose(); }
public FolderDeletedDescriptor(MAPINtf ntf, string storeID) { Guard.NullArgument(ntf, "ntf"); Guard.EmptyStringArgument(storeID, "storeID"); _ntf = ntf; _storeID = storeID; // The notification contains only the short-term entry ID, and since the // folder has already been deleted, it is no longer possible to get the // long-term entry ID. Thus, we need to scan the children of the parent of // the deleted folder and check if all of them still exist. IResource resFolder = Folder.Find(ntf.EntryID); if (resFolder == null) { IEFolder parentFolder = OutlookSession.OpenFolder(ntf.ParentID, storeID); if (parentFolder != null) { using ( parentFolder ) { string parentId = OutlookSession.GetFolderID(parentFolder); IResource parentMAPIFolder = Folder.Find(parentId); if (parentMAPIFolder == null) { parentMAPIFolder = Folder.Find(ntf.ParentID); } if (parentMAPIFolder != null) { IResourceList childFolders = parentMAPIFolder.GetLinksTo("MAPIFolder", "Parent"); foreach (IResource childFolderRes in childFolders) { IEFolder childFolder = OutlookSession.OpenFolder(childFolderRes.GetStringProp("EntryID"), storeID); if (childFolder != null) { childFolder.Dispose(); } else { _entryId = childFolderRes.GetStringProp("EntryID"); } } if (_entryId == null) { HashSet set = new HashSet(childFolders.Count); foreach (IResource childFolderRes in childFolders) { set.Add(childFolderRes.GetStringProp("EntryID")); } IEFolders folders = OutlookSession.GetFolders(parentFolder); if (folders != null) { using ( folders ) { for (int i = 0; i < folders.GetCount(); ++i) { IEFolder folder = OutlookSession.OpenFolder(folders, i); if (folder != null) { using ( folder ) { string entryId = folder.GetBinProp(MAPIConst.PR_ENTRYID); if (entryId != null) { set.Remove(entryId); } } } } } } foreach (HashSet.Entry entry in set) { _entryId = (string)entry.Key; break; } if (_entryId == null && Retry) { OutlookSession.OutlookProcessor.QueueJobAt(DateTime.Now.AddMinutes(2), "Delete folder", new MethodInvoker(CreateFolderDeletedDescriptor)); } } } } } } else { _entryId = ntf.EntryID; } }