private bool TryOpenHistoryFolder() { bool result; try { MapiStore mapiStore = this.context.StoreSession.Mailbox.MapiStore; using (MapiFolder nonIpmSubtreeFolder = mapiStore.GetNonIpmSubtreeFolder()) { this.oofHistoryFolder = nonIpmSubtreeFolder.OpenSubFolderByName("Freebusy Data"); } this.Trace("OOF history folder opened."); result = true; } catch (MapiExceptionNotFound mapiExceptionNotFound) { this.context.TraceError <string>("Unable to open the OOF history folder {0}, OOF history operation skipped.", "Freebusy Data"); this.context.LogEvent(this.context.OofHistoryFolderMissing, mapiExceptionNotFound.GetType().ToString(), new object[] { ((MailboxSession)this.context.StoreSession).MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString() }); result = false; } return(result); }
internal static MapiFolder GetFolderByPath(MapiStore mapiStore, MapiFolder parentFolder, MapiFolderPath folderPath) { if (null == folderPath) { throw new ArgumentNullException("folderPath"); } if (folderPath.IsSubtreeRoot) { if (mapiStore == null) { throw new ArgumentNullException("mapiStore"); } if (!folderPath.IsIpmPath) { return(mapiStore.GetNonIpmSubtreeFolder()); } return(mapiStore.GetIpmSubtreeFolder()); } else { if (parentFolder == null) { throw new ArgumentNullException("parentFolder"); } return(parentFolder.OpenSubFolderByName(folderPath[folderPath.Depth - 1])); } }
private static bool TryOpenFolder(MailboxSession itemStore, out MapiFolder nonIpmSubtreeFolder, out MapiFolder oofHistoryFolder) { MapiStore _ContainedMapiStore = itemStore.__ContainedMapiStore; nonIpmSubtreeFolder = _ContainedMapiStore.GetNonIpmSubtreeFolder(); oofHistoryFolder = null; if (nonIpmSubtreeFolder == null) { OofHistory.Tracer.TraceError((long)itemStore.GetHashCode(), "Unable to open the non ipm subtree folder, OOF history operation is not executed."); return(false); } try { oofHistoryFolder = nonIpmSubtreeFolder.OpenSubFolderByName("Freebusy Data"); } catch (MapiExceptionNotFound) { OofHistory.Tracer.TraceError <string>((long)itemStore.GetHashCode(), "Unable to open the OOF history folder {0}, OOF history operation is not executed.", "Freebusy Data"); return(false); } return(true); }
internal static MapiFolder GetFolderByPath(MapiStore mapiStore, MapiFolderPath folderPath, out MapiFolder parent) { if (mapiStore == null) { throw new ArgumentNullException("mapiStore"); } if (null == folderPath) { throw new ArgumentNullException("folderPath"); } parent = null; MapiFolder mapiFolder = null; bool flag = false; MapiFolder result; try { mapiFolder = (folderPath.IsIpmPath ? mapiStore.GetIpmSubtreeFolder() : mapiStore.GetNonIpmSubtreeFolder()); int num = 0; while (folderPath.Depth - 1 > num) { MapiFolder mapiFolder2; parent = (mapiFolder2 = mapiFolder); using (mapiFolder2) { mapiFolder = parent.OpenSubFolderByName(folderPath[num]); } num++; } if (folderPath.Depth - 1 == num) { if (parent != null) { parent.Dispose(); parent = null; } parent = mapiFolder; mapiFolder = parent.OpenSubFolderByName(folderPath[num]); } if (parent == null) { parent = mapiStore.GetRootFolder(); } flag = true; result = mapiFolder; } finally { if (!flag) { if (mapiFolder != null) { mapiFolder.Dispose(); mapiFolder = null; } if (parent != null) { parent.Dispose(); parent = null; } } } return(result); }