Beispiel #1
0
        internal static void Detect()
        {
            if (!Settings.DetectOwnerEmail)
            {
                return;
            }
            IEMsgStore defStore = OutlookSession.GetDefaultMsgStore();

            if (defStore == null)
            {
                return;
            }
            string folderId = defStore.GetBinProp(MAPIConst.PR_IPM_SENTMAIL_ENTRYID);

            if (folderId == null)
            {
                return;
            }
            string storeID = defStore.GetBinProp(MAPIConst.PR_ENTRYID);

            if (storeID == null)
            {
                return;
            }
            IEFolder folder = OutlookSession.OpenFolder(folderId, storeID);

            if (folder == null)
            {
                return;
            }
            using ( folder )
            {
                ProcessFolder(folder);
            }
        }
Beispiel #2
0
        internal static bool IsIgnoredInfoStore(IEMsgStore msgStore)
        {
            Trace.WriteLine("IsIgnoredInfoStore -- checking infostore: ");
            string entryId = msgStore.GetBinProp(MAPIConst.PR_ENTRYID);

            if (entryId != null)
            {
                IResource infoStore = Core.ResourceStore.FindUniqueResource(STR.MAPIInfoStore, PROP.EntryID, entryId);

                if (infoStore != null)
                {
                    if (infoStore.HasProp(Core.Props.Name))
                    {
                        Trace.WriteLine("      IsIgnoredInfoStore -- with name [" + infoStore.GetStringProp(Core.Props.Name) + "]");
                    }

                    int prop = infoStore.GetIntProp(PROP.IgnoredFolder);
                    if (prop != 0)
                    {
                        Trace.WriteLine("      IsIgnoredInfoStore -- FLAG IgnoredFolder is set!");
                    }

                    return(infoStore.GetIntProp(PROP.IgnoredFolder) != 0);
                }
                else
                {
                    Trace.WriteLine("      IsIgnoredInfoStore -- No InfoStore resource found.");
                }
            }

            Trace.WriteLine("IsIgnoredInfoStore -- It has no PR_ENTRYID, trying DeletedItemsEntryID");
            string deletedItemsEntryId = msgStore.GetBinProp(MAPIConst.PR_IPM_WASTEBASKET_ENTRYID);

            if (deletedItemsEntryId != null)
            {
                IResource infoStore = Core.ResourceStore.FindUniqueResource(STR.MAPIInfoStore,
                                                                            PROP.DeletedItemsEntryID, deletedItemsEntryId);
                if (infoStore != null)
                {
                    if (infoStore.HasProp(Core.Props.Name))
                    {
                        Trace.WriteLine("IsIgnoredInfoStore -- with name [" + infoStore.GetStringProp(Core.Props.Name) + "]");
                    }

                    int prop = infoStore.GetIntProp(PROP.IgnoredFolder);
                    if (prop != 0)
                    {
                        Trace.WriteLine("IsIgnoredInfoStore -- FLAG IgnoredFolder is set!");
                    }

                    return(infoStore.GetIntProp(PROP.IgnoredFolder) != 0);
                }
                else
                {
                    Trace.WriteLine("      IsIgnoredInfoStore -- No InfoStore resource found.");
                }
            }
            Trace.WriteLine("IsIgnoredInfoStore -- It has no PR_IPM_WASTEBASKET_ENTRYID");

            return(false);
        }
Beispiel #3
0
        public static void Initialize()
        {
            try
            {
                _outlookVersion = GetOutlookVersionFromRegistry();
            }
            catch (Exception ex)
            {
                Core.AddExceptionReportData("\nError getting Outlook version from registry: " + ex.Message);
                Trace.WriteLine("Error getting Outlook version from registry: " + ex.Message);
                _outlookVersion = 0;
            }
            ReportOutlookAddins();
            ReportOutlookExtensions();
            _eSession = new EMAPISession(0);
            _eSession.CheckDependencies();
            try
            {
                if (!_eSession.Initialize(IsPickLogonProfile(), _libManager))
                {
                    throw new Exception("MAPI logon failed");
                }
            }
            catch (COMException exception)
            {
                _tracer.TraceException(exception);
                Core.ReportBackgroundException(exception);
                throw new Exception("MAPI logon failed: " + exception.Message);
            }
            _addressBook = _eSession.OpenAddrBook();
            IEMsgStores stores = _eSession.GetMsgStores();

            if (stores != null)
            {
                using ( stores )
                {
                    int count = stores.GetCount();
                    Trace.WriteLine("*********************************************************");
                    Trace.WriteLine("* " + count + " MAPI stores detected");
                    for (int i = 0; i < count; ++i)
                    {
                        IEMsgStore store = null;
                        try
                        {
                            store = stores.GetMsgStore(i);
                        }
                        catch (EMAPILib.ProblemWhenOpenStorage ex)
                        {
                            Trace.WriteLine("* " + i + "th store caused problem while getting the IEMsgStore resource");
                            ProblemWithOpeningStorage(ex);
                        }
                        if (store == null)
                        {
                            continue;
                        }

                        string storeID = stores.GetStorageID(i);
                        _msgStores.Add(storeID, store);
                        Trace.WriteLine("* " + i + "th store has StoreID [" + storeID + "]");

                        if (Settings.UseOutlookListeners)
                        {
                            try
                            {
                                MAPIListenerStub mapiListener = new MAPIListenerStub(new MAPIListener(storeID));
                                store.Advise(mapiListener);
                            }
                            catch (Exception exception)
                            {
                                _tracer.TraceException(exception);
                                //SetLastException( exception );
                            }
                        }

                        if (stores.IsDefaultStore(i))
                        {
                            Trace.WriteLine("* " + i + "th store is a default store");
                            _defaultMsgStore = store;
                            string delEntryID = _defaultMsgStore.GetBinProp(MAPIConst.PR_IPM_WASTEBASKET_ENTRYID);
                            _deletedFolderIDs = new PairIDs(delEntryID, storeID);
                        }
                    }
                    Trace.WriteLine("*********************************************************");
                }
            }
            if (_defaultMsgStore == null)
            {
                throw new ApplicationException("There is no default storage");
            }
        }
Beispiel #4
0
        public MAPIInfoStoreDescriptor(IEMsgStore msgStore)
        {
            _name           = msgStore.GetStringProp(MAPIConst.PR_DISPLAY_NAME);
            _entryId        = msgStore.GetBinProp(MAPIConst.PR_ENTRYID);
            _deletedItemsId = msgStore.GetBinProp(MAPIConst.PR_IPM_WASTEBASKET_ENTRYID);

            MAPIIDs mapiIds = msgStore.GetInboxIDs();

            if (mapiIds != null)
            {
                AddDefaultFolderEntryID(mapiIds.EntryID);
            }
            AddDefaultFolderEntryID(_deletedItemsId);
            AddDefaultFolderEntryID(msgStore.GetBinProp(MAPIConst.PR_IPM_SENTMAIL_ENTRYID));
            AddDefaultFolderEntryID(msgStore.GetBinProp(MAPIConst.PR_IPM_OUTBOX_ENTRYID));

            IEFolder rootFolder = msgStore.GetRootFolder();

            if (rootFolder != null)
            {
                using ( rootFolder )
                {
                    string parentEntryId = rootFolder.GetBinProp(MAPIConst.PR_PARENT_ENTRYID);
                    if (parentEntryId != null)
                    {
                        IEFolder parentFolder = msgStore.OpenFolder(parentEntryId);
                        if (parentFolder != null)
                        {
                            using ( parentFolder )
                            {
                                AddDefaultFolderEntryID(parentFolder.GetBinProp(MAPIConst.PR_IPM_APPOINTMENT_ENTRYID));
                                AddDefaultFolderEntryID(parentFolder.GetBinProp(MAPIConst.PR_IPM_CONTACT_ENTRYID));
                                AddDefaultFolderEntryID(parentFolder.GetBinProp(MAPIConst.PR_IPM_DRAFTS_ENTRYID));
                                AddDefaultFolderEntryID(parentFolder.GetBinProp(MAPIConst.PR_IPM_JOURNAL_ENTRYID));
                                AddDefaultFolderEntryID(parentFolder.GetBinProp(MAPIConst.PR_IPM_NOTE_ENTRYID));
                                AddDefaultFolderEntryID(parentFolder.GetBinProp(MAPIConst.PR_IPM_TASK_ENTRYID));
                                ArrayList additionalRenEntryIDs = parentFolder.GetBinArray(MAPIConst.PR_ADDITIONAL_REN_ENTRYIDS);
                                if (additionalRenEntryIDs != null && additionalRenEntryIDs.Count > 4)
                                {
                                    _junkEmailId = additionalRenEntryIDs[4] as string;
                                }
                                if (additionalRenEntryIDs != null)
                                {
                                    foreach (string id in additionalRenEntryIDs)
                                    {
                                        AddDefaultFolderEntryID(id);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            _supportMask = msgStore.GetLongProp(MAPIConst.PR_STORE_SUPPORT_MASK);

            _resource         = Core.ResourceStore.FindUniqueResource(STR.MAPIInfoStore, PROP.EntryID, _entryId);
            _storeTypeChecked = _resource == null?false:_resource.HasProp(PROP.StoreTypeChecked);
            if (_resource == null || !_storeTypeChecked)
            {
                try
                {
                    _supported        = OutlookSession.IsStorageSupported(msgStore);
                    _storeTypeChecked = true;
                }
                catch (COMException exception)
                {
                    Tracer._TraceException(exception);
                }
            }
            else
            {
                _supported = _resource.HasProp(PROP.StoreSupported);
            }
        }