public static IEFolders GetFolders(IEFolder folder, FolderDescriptor folderDescriptor) { try { if (folderDescriptor == null) { folderDescriptor = FolderDescriptor.Get(folder); } return(folder.GetFolders()); } catch (COMException exception) { _tracer.TraceException(exception); OutlookSession.ProblemWithOpeningFolder(folderDescriptor.FolderIDs.EntryId); } return(null); }
private void SynchronizeFolderRecursive(IEFolder folder, string name, string storeID, FolderDescriptor parentDescriptor) { if (folder == null) { return; } using ( folder ) { FolderDescriptor folderDescriptor = FolderDescriptor.Get(folder); if (name != null) { folderDescriptor.Name = name; _tracer.Trace("Folder name = " + name); } else { _tracer.Trace("Folder name is unknown"); } _folders.Remove(folderDescriptor.FolderIDs.EntryId); FolderStructureDescriptor folderStruct = new FolderStructureDescriptor(parentDescriptor, folderDescriptor); Core.ResourceAP.QueueJob(folderStruct); IEFolders folders = OutlookSession.GetFolders(folder, folderDescriptor); if (folders == null) { return; } using ( folders ) { for (int i = 0; i < folders.GetCount(); ++i) { try { SynchronizeFolderRecursive(folders.OpenFolder(i), null, storeID, folderDescriptor); } catch (COMException exception) { _tracer.TraceException(exception); OutlookSession.ProblemWithOpeningFolder(folderDescriptor.FolderIDs.EntryId); break; } } } } }
public static IEMessage OpenMessage(string parentFolderId, IEFolder folder, string entryId) { try { return(OpenMessage(folder, entryId)); } catch (COMException exception) { if (exception.ErrorCode == (unchecked ((int)0x8004060E))) //Folder is in offline mode { OutlookSession.ProblemWithOpeningFolder(parentFolderId); return(null); } if (exception.ErrorCode == (unchecked ((int)0x80004005)) || exception.ErrorCode == (unchecked ((int)0x80040608))) { return(null); } throw exception; } }
public void EnumerateMessageItems(FolderDescriptor folderDescriptor) { if (OutlookSession.WereProblemWithOpeningStorage(folderDescriptor.FolderIDs.StoreId) || OutlookSession.WereProblemWithOpeningFolder(folderDescriptor.FolderIDs.EntryId)) { return; } try { IEFolder mapiFolder = OutlookSession.OpenFolder(folderDescriptor.FolderIDs.EntryId, folderDescriptor.FolderIDs.StoreId); if (mapiFolder == null) { return; } using ( mapiFolder ) { string containerClass = mapiFolder.GetStringProp(MAPIConst.PR_CONTAINER_CLASS); bool taskFolder = (FolderType.Task.Equals(containerClass)); if (taskFolder) { EnumerateTasks(folderDescriptor, mapiFolder); } else { EnumerateMail(folderDescriptor, mapiFolder); } } } catch (COMException exception) { _tracer.TraceException(exception); if (exception.ErrorCode == MapiError.MAPI_E_NOT_ENOUGH_DISK) { StandartJobs.MessageBox("Outlook reports that there is no enough disk space.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } OutlookSession.ProblemWithOpeningFolder(folderDescriptor.FolderIDs.EntryId); return; } }
public static IEFolder OpenFolder(IEFolders folders, int index) { try { return(folders.OpenFolder(index)); } catch (COMException exception) { if (exception.ErrorCode == (unchecked ((int)0x8004060E)) || exception.ErrorCode == MapiError.MAPI_E_NETWORK_ERROR || exception.ErrorCode == MapiError.MAPI_E_FAILONEPROVIDER) //Folder is in offline mode or Network error { OutlookSession.ProblemWithOpeningFolder(folders.GetEntryId(index)); return(null); } if (exception.ErrorCode == MapiError.MAPI_E_EXTENDED_ERROR) { OutlookSession.ProblemWithOpeningFolder(folders.GetEntryId(index)); return(null); } throw exception; } }