VBA: Cannot get public folders anymore RRS feed

  • Question

  • Hi

    Sorry if i have posted this in wrong category.

    I have thousands of code lines and some of the functions doesn't seem to work anymore.

    i had to make a full backup of my exchange server in order of replacing larger disks. Restore went well and all mail clients (outlook and Mobil Active Sync) still works perfectly with out any change on the clients.

    But i have this VBA code which not is working anymore. It code I have borroewd form her Getfoler and the codes goes like this:

    Public Function GetFolder(strFolderPath As String)As MAPIFolder
      ' strFolderPath needs to be something like 
      '   "Public Folders\All Public Folders\Company\Sales" or
      '   "Personal Folders\Inbox\My Folder"
      Dim objApp As Outlook.Application
      Dim objNS As Outlook.NameSpace
      Dim colFolders As Outlook.Folders
      Dim objFolder As Outlook.MAPIFolder
      Dim arrFolders() As String
      Dim I As Long
      On Error Resume Next
      strFolderPath = Replace(strFolderPath, "/", "\")
      arrFolders() = Split(strFolderPath, "\")
      Set objApp = Application
      Set objNS = objApp.GetNamespace("MAPI")
      Set objFolder = objNS.Folders.Item(arrFolders(0))
      If Not objFolder Is Nothing Then
        For I = 1 To UBound(arrFolders)
          Set colFolders = objFolder.Folders
          Set objFolder = Nothing
          Set objFolder = colFolders.Item(arrFolders(I))
          If objFolder Is Nothing Then
            Exit For
          End If
      End If
      Set GetFolder = objFolder
      Set colFolders = Nothing
      Set objNS = Nothing
      Set objApp = Nothing
    End Function

    When running the code line by line i can see that objApp is "Outlook" as it should be but objNS does not get assignet to anything only "Nothing" :-(. I believe it's quite strange. The Outlook client I am running the code from is version

    Have there been made any changes in that particullar version regarding MAPI-folders? I know we have been able to run the code in earlier versions of Outlook 2016. At the moment the code also runs perfectly from Outlook 2010.  

    Beside from restoring the Exchange Server back and Office Updates nothing has changed. I do have the application MFCMAPI x86 which connects perfectly but I don't know if I can use this tool to verify my needs on getting hold of public folders.

    Anybody wih suggestions?

     - Allan

    Wednesday, January 4, 2017 10:51 AM