
"Unknown error" using GetFolderFromID method
I get a reproducible error that occurs every once in a while. I'm using
Outlook 2000. I've written a procedure for Word that reads addresses from a
contact folder. The ID number for the folder is stored in the registry so
the user does not have to keep selecting the same folder over and over
again.
Every once in a while (and I have not been able to determine what
combination of actions causes this) I get the following error message when
executing the GetFolderFromID method:
"The messaging interface has returned an unknown error. If the problem
persists, restart Outlook".
If I then re-select the same folder I do not get the error, even thought the
ID number is exactly the same.
Here is the code fragment.
To select the folder and store the folder ID in the registry I use:
Dim golApp As Outlook.Application
Dim gnspNameSpace As Outlook.NameSpace
Dim objTopFolder As Outlook.MAPIFolder
Set golApp = New Outlook.Application
Set gnspNameSpace = golApp.GetNamespace("MAPI")
Set objTopFolder = gnspNameSpace.PickFolder
....code here to confirm that the selected folder is a contact
folder
gstrContactFolderID = objTopFolder.EntryID
The gstrContactFolderID value is then saved to registry with
System.ProfileString method.
When the user wants to get contact data the code is:
Dim golApp As Outlook.Application
Dim gnspNameSpace As Outlook.NameSpace
Dim objContactFolder As Outlook.MAPIFolder
Set golApp = New Outlook.Application
Set gnspNameSpace = golApp.GetNamespace("MAPI")
Set objContactFolder = gnspNameSpace.GetFolderFromID(strFolderID)
<<<Error occurs here
where strFolderID is the folder ID from the registry.
The error occurs at the last line. If I immediate re-select the same folder
and the run the second fragment it works fine. On the other hand, if I
re-run the second fragment without reselecting the folder the error number
keeps changing. I've gotten error numbers such as:
-2079063551
-1836842495
-1490812415
-1421606399
-1352400383
-1283194367
ad infinitum...
In all instances there already is an instance of Outlook running before
either of the code fragments are run.
The folder being accessed is two levels down the "Public Folders" tree (i.e.
Public Folders\Office\Addresses).
I couldn't find anything in TechNet or MSDN that applies. Any suggestions
would be appreciated.