Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    May 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question [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.

    Any ideas??


    What is the problem?
    Last edited by Geir Nordvik; 2014-05-08 at 02:56. Reason: Solved

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    660
    Thanks
    3
    Thanked 19 Times in 18 Posts
    Is the error code because you're trying to reassign the object "fFolder" without using "Set"? Does it work to use something like this:

    Code:
    Set ns = GetNamespace("MAPI")
    Set fTopFolder = ns.GetDefaultFolder(olFolderInbox)
    Set fFolder = fTopFolder.Folders("TestFolder")
    Just a thought -- I haven't tested. Best, Kim

  4. The Following User Says Thank You to kmurdock For This Useful Post:

    Geir Nordvik (2014-05-08)

  5. #3
    New Lounger
    Join Date
    May 2014
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you - did the trick :-)
    Geir

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •