GAL in outlook RRS feed

  • Question

  • Hi

    I have a code which fetches the details of the users (Alias, ManagerName) using Outlook Object. (Code snippet below).  The code works perfectly fine until Friday.  Since Monday (6.30.2014) it started failing with error message "The attempted operation failed.  An object could not be found. [-2147221233]"

    When I debugged the code, it's failing at this point, "Set oGAL = oDLs.Item("All Groups")".  Any pointers would be highly appreciated.  I'm using this code in Access 2010 to get the list of members in an Outlook Distribution list.


        ' Initialize a new instance of Outlook Application NOTE: Outlook needs to be open to be able to fetch the DL details
        Set oApp = New Outlook.Application
        Set oNS = oApp.GetNamespace("mapi")

        Set oDLs = oNS.AddressLists

        Set oGAL = oDLs.Item("All Groups")
        Set oEntries = oGAL.AddressEntries
        Set oDL = oEntries.Item(cDLName)

        cDLNameinOutlook = ReplaceString(oDL.Name, Space(1), "")
        cDLNameinOutlook = ReplaceString(cDLNameinOutlook, Chr(150), "")
        cDLNameinOutlook = ReplaceString(cDLNameinOutlook, Chr(45), "")
        cDLNameInDLM = ReplaceString(rst!FullDLName, Space(1), "")
        cDLNameInDLM = ReplaceString(cDLNameInDLM, Chr(150), "")
        cDLNameInDLM = ReplaceString(cDLNameInDLM, Chr(45), "")

         If cDLNameInDLM = cDLNameinOutlook Then

                ' Get all of the members of the distribution list.
                Set oMemberEntries = oDL.Members
                On Error GoTo EH_NotResolved

                ' Loop through each members in the DL
                For i = 1 To oMemberEntries.Count
                    On Error GoTo EH_Individual
                    Set oEntry = oMemberEntries.Item(i)

                    cUserName = oEntry.Name
                    cLANID = Left(oEntry.GetExchangeUser.Alias, 20)
                    cEMail = oEntry.GetExchangeUser.PrimarySmtpAddress
                    cOffice = oEntry.GetExchangeUser.OfficeLocation


    Tuesday, July 1, 2014 5:48 AM


  • Hello Ravi,

    Did you try to access "All Groups" in Outlook manually? Is there such entry in the distribution list?

    • Marked as answer by Maaman Ravi Thursday, July 3, 2014 4:56 AM
    Wednesday, July 2, 2014 10:32 AM

All replies