Beispiel #1
0
        /// <summary>
        /// Finds the Global Address List associated with the MailStore
        /// </summary>
        /// <returns>OLAddressList for GAL or null if store has no GAL</returns>
        public IAddressBook GetGlobalAddressList()
        {
            string PR_EMSMDB_SECTION_UID = @"http://schemas.microsoft.com/mapi/proptag/0x3D150102";

            if (_store == null)
            {
                throw new ArgumentNullException();
            }

            Outlook.PropertyAccessor oPAStore = _store.PropertyAccessor;
            string storeUID = oPAStore.BinaryToString(oPAStore.GetProperty(PR_EMSMDB_SECTION_UID));

            foreach (Outlook.AddressList addrList in _store.Session.AddressLists)
            {
                Outlook.PropertyAccessor oPAAddrList = addrList.PropertyAccessor;
                string addrListUID = oPAAddrList.BinaryToString(oPAAddrList.GetProperty(PR_EMSMDB_SECTION_UID));

                // Returns addrList if match on storeUID
                // and type is olExchangeGlobalAddressList.
                if (addrListUID == storeUID && addrList.AddressListType ==
                    Outlook.OlAddressListType.olExchangeGlobalAddressList)
                {
                    return(new AddressBookProviderOM(addrList));
                }
            }

            return(null);
        }
        /// <summary>
        /// Loads the namespaces into memory
        /// </summary>
        private void LoadNamespaceInfo()
        {
            int iCount = 0; // for namespaces

            // build and create a list of namespaces for each account loaded in Outlook
            // what we will do is create an entry for every account since we do not know if
            // which one the add-in is loaded in. It could be one, or all
            MobjAccountUIDs = new Dictionary <string, string>();
            // loop through each account and add a ribbon NS element for each one
            foreach (Outlook.Account account in Globals.ThisAddIn.Application.Session.Accounts)
            {
                iCount++;
                Outlook.PropertyAccessor propertyAccessor = account.CurrentUser.PropertyAccessor;
                string ns = "x" + iCount.ToString();
                MobjAccountUIDs.Add(ns, MstrWebAddinID + "_" + propertyAccessor.BinaryToString(propertyAccessor.GetProperty(PR_EMSMDB_SECTION_UID)));
                break;
            }
        }
Beispiel #3
0
        private Outlook.AddressList GetGlobalAddressList(Outlook.Application outlookApp, Outlook.Store store)
        {
            // Property string for the UID of a store or address list.
            string PR_EMSMDB_SECTION_UID =
                @"http://schemas.microsoft.com/mapi/proptag/0x3D150102";

            if (store == null)
            {
                throw new ArgumentNullException();
            }

            // Obtain the store UID using the proprety string and
            // property accessor on the store.
            Outlook.PropertyAccessor oPAStore = store.PropertyAccessor;

            // Convert the store UID to a string value.
            string storeUID = oPAStore.BinaryToString(oPAStore.GetProperty(PR_EMSMDB_SECTION_UID));

            // Enumerate each address list associated
            // with the session.
            foreach (Outlook.AddressList addrList in outlookApp.Session.AddressLists)
            {
                // Obtain the address list UID and convert it to
                // a string value.
                Outlook.PropertyAccessor oPAAddrList = addrList.PropertyAccessor;
                string addrListUID = oPAAddrList.BinaryToString(oPAAddrList.GetProperty(PR_EMSMDB_SECTION_UID));

                // Return the address list associated with the store
                // if the address list UID matches the store UID and
                // type is olExchangeGlobalAddressList.
                if (addrListUID == storeUID && addrList.AddressListType == Outlook.OlAddressListType.olExchangeGlobalAddressList)
                {
                    return(addrList);
                }
            }

            return(null);
        }
 private static Outlook.MAPIFolder GetCommonViewsFolder()
 {
     try
     {
         if (null == m_NameSpace)
         {
             Initialise();
         }
         Outlook.Store            olStore            = m_NameSpace.DefaultStore;
         Outlook.PropertyAccessor olPropertyAccessor = olStore.PropertyAccessor;
         string commonViewsEntryId = olPropertyAccessor.BinaryToString(olPropertyAccessor.GetProperty(PR_COMMON_VIEWS_ENTRY_ID));
         if (commonViewsEntryId != string.Empty)
         {
             return(m_NameSpace.GetFolderFromID(commonViewsEntryId));
         }
         return(null);
     }
     catch (Exception exception)
     {
         Console.WriteLine("Unable to get common views folder. Error: " + exception.ToString());
         return(null);
     }
 }