[SOLVED] "No permission" error when accessing Outlook folders from Acces VBA
I am trying to access subfolders under the Inbox folder in Outlook from Access VBA. It is my own Inbox and I'm running Access on my own computer logged in as myself. The code that causes trouble looks like this:
Set ns = GetNamespace("MAPI")
Set fFolder = ns.GetDefaultFolder(olFolderInbox)
fFolder = fFolder.Folders("TestFolder")
The last line gives the following runtime error:
Run-time error '-2147024891 (80070005)'
You don't have permission to perform this operation
This error pops up no matter what subfolder I am trying to access from the code - not only the TestFolder.
The folders I am trying to access (TestFolder etc.) are subfolders in my own e-mail Inbox. There is nothing strange with them - they contain e-mail messages that I have dragged-and-dropped from the Inbox. I can do whatever I want with these subfolders in Outlook - so I seem to have all the permissions I need. If I look under the "Permissions" tab I am listed there with "Owner" permission level. I have tried some other permission settings, but no success so far.
I guess this is a permission issue? I am running this Access application on my own PC - logged in as myself.
Or is there somehing wrong with my code?
There is more VBA code than this of course. Before the code above is executed I execute code to read the folder structure in Outlook and store all the folders in a table in the access database. This works fine - all my subfolders and subfolders under subfolders are perferctly "visible" from Access VBA, and the foldernames and folderpaths are all correct. However, I do not "path my way down" using the fFolders.Folders(SubFolder) structure anywhere else than in the "problematic code" above.
What is the problem?