none
Get Global Address List for Store in Outlook 2007 RRS feed

  • Question

  • Hey guys,

    I'm using an Outlook 2010 example (http://msdn.microsoft.com/en-us/library/office/ff184631.aspx) in my Outlook Add-In to display the global address list of a store.

    void DisplayGlobalAddressListForStore()
    {
        Outlook.Folder currentFolder =
            Application.ActiveExplorer().CurrentFolder
            as Outlook.Folder;
        Outlook.Store currentStore = currentFolder.Store;
        if (currentStore.ExchangeStoreType !=
            Outlook.OlExchangeStoreType.olNotExchange)
        {
            Outlook.SelectNamesDialog snd = 
                Application.Session.GetSelectNamesDialog();
            Outlook.AddressList addrList = 
                GetGlobalAddressList(currentStore);
            if (addrList != null)
            {
                snd.InitialAddressList = addrList;
                snd.Display();
            }
        }
    }
    
    public Outlook.AddressList GetGlobalAddressList(Outlook.Store store)
    {
        string  PR_EMSMDB_SECTION_UID = 
            @"http://schemas.microsoft.com/mapi/proptag/0x3D150102";
        if (store == null)
        {
            thrownew ArgumentNullException();
        }
        Outlook.PropertyAccessor oPAStore = store.PropertyAccessor;
        string storeUID = oPAStore.BinaryToString(
            oPAStore.GetProperty(PR_EMSMDB_SECTION_UID));
        foreach (Outlook.AddressList addrList 
            in Application.Session.AddressLists)
        {
            Outlook.PropertyAccessor oPAAddrList = 
                addrList.PropertyAccessor;
            string addrListUID = oPAAddrList.BinaryToString(
                oPAAddrList.GetProperty(PR_EMSMDB_SECTION_UID));
            // Return addrList if match on storeUID// and type is olExchangeGlobalAddressList.if (addrListUID == storeUID && addrList.AddressListType ==
                Outlook.OlAddressListType.olExchangeGlobalAddressList)
            {
                return addrList;
            }
        }
        returnnull;
    }

    The Add-In needs to support Outlook 2007 and later. Now my problem is that Outlook 2007 doesn't support the MAPI property tag PR_EMSMDB_SECTION_UID used in the GetGlobalAddressList(..) method. Outlook 2010 and later works fine!

    I get the following error:

    Detailed technical information follows: 
    ---
    (Inner Exception)
    Date and Time:         15.11.2012 10:13:06
    Machine Name:          VM01-SATURN-24
    IP Address:            fe80::a413:48d6:95ac:5181%10
    Current User:          vm01-saturn-24\Administrator
    
    Application Domain:    C:\Users\Administrator.vm01-saturn-24\Desktop\Debug\
    Assembly Codebase:     file:///C:/Users/Administrator.vm01-saturn-24/Desktop/Debug/AddinExpress.MSO.2005.DLL
    Assembly Full Name:    AddinExpress.MSO.2005, Version=7.0.4023.2005, Culture=neutral, PublicKeyToken=4416dd98f0861965
    Assembly Version:      7.0.4023.2005
    
    Exception Source:      Microsoft Office Outlook
    Exception Type:        System.Runtime.InteropServices.COMException
    Exception Message:     The property "http://schemas.microsoft.com/mapi/proptag/0x3D150102" is unknown or cannot be found.
    Exception Target Site: GetProperty
    
    ---- Stack Trace ----
       Microsoft.Office.Interop.Outlook.PropertyAccessorClass.GetProperty(SchemaName As String)
           AddinExpress.MSO.2005.DLL: N 00000 (0x0) JIT 
       MsOutlookAddin.PhoneDialer.PhoneDialerForm.GetGlobalAddressList(store As Store)
           PhoneDialerForm.cs: line 1225, col 13, IL 0028 (0x1C)
       MsOutlookAddin.PhoneDialer.PhoneDialerForm.DisplayGlobalAddressListForStore(name As String)
           PhoneDialerForm.cs: line 1175, col 17, IL 0084 (0x54)
       MsOutlookAddin.PhoneDialer.PhoneDialerForm.SetItem(mailItem As MailItem)
           PhoneDialerForm.cs: line 0495, col 17, IL 0030 (0x1E)
       MsOutlookAddin.PhoneDialer.PhoneDialerForm..ctor(addIn As AddinModule, mailItem As MailItem)
           PhoneDialerForm.cs: line 0116, col 13, IL 0009 (0x9)
       MsOutlookAddin.PhoneDialer.AddinModule.adxRibbonButtonInitiateCall_OnClick(sender As Object, control As IRibbonControl, pressed As Boolean)
           AddinModule.cs: line 0575, col 29, IL 0456 (0x1C8)
       MsOutlookAddin.PhoneDialer.AddinModule.adxCommandBarButtonInitiateCall_Click(sender As Object)
           AddinModule.cs: line 0708, col 13, IL 0001 (0x1)
       AddinExpress.MSO.ADXCommandBarButton.OnButtonClick(button As ICommandBarButton, handled As Boolean&)
           AddinExpress.MSO.2005.DLL: N 0053 (0x35) IL 
    
    
    
    (Outer Exception)
    Date and Time:         15.11.2012 10:13:06
    Machine Name:          VM01-SATURN-24
    IP Address:            fe80::a413:48d6:95ac:5181%10
    Current User:          vm01-saturn-24\Administrator
    
    Application Domain:    C:\Users\Administrator.vm01-saturn-24\Desktop\Debug\
    Assembly Codebase:     file:///C:/Users/Administrator.vm01-saturn-24/Desktop/Debug/AddinExpress.MSO.2005.DLL
    Assembly Full Name:    AddinExpress.MSO.2005, Version=7.0.4023.2005, Culture=neutral, PublicKeyToken=4416dd98f0861965
    Assembly Version:      7.0.4023.2005
    
    Exception Source:      
    Exception Type:        AddinExpress.MSO.ADXExternalException
    Exception Message:     An error has occurred in the code of the add-in.
    Exception Target Site: Object reference not set to an instance of an object.
    
    ---- Stack Trace ----

    Do you guys have any idea how to check if the AddressList object belongs to the Store object without any MAPI property tag? I already checked any existing property like AddressList.ID and Store.StoreID but they are different.

    BTW: I use Add-In Express for .NET (latest version: 7.0.4023.2005)

    Best regards,
    Arkadius


    • Edited by Arkadius J Thursday, November 15, 2012 9:22 AM
    Thursday, November 15, 2012 9:20 AM

Answers

All replies