none
Get search folders of shared mailbox with VBA RRS feed

  • Question

  • I have a permission problem trying to get the items of a search folder of a shared mailbox in Outlook 2007. 

    I'm using the following method to get the folder, which works fine with my local mailbox:

    CODE:

        Set oFolder = Session.Stores.item(strFoldername).GetSearchFolders("New mails") ' ofolder is an outlook.Folder object

    -------------------

    When this method is used on a shared mailbox, the following error message appears: 

    -------------------------------------------------------------------------------

    Run-time error '-2147352567 (80020009)'

    You don't have appropriate permission to perform this operation.

    -------------------------------------------------------------------------------

    Even if I set the permissions of the shared mailbox to 'Owner' level I can't use the 'GetSearchFolders()' function. Could you tell me what permission settings have to be set to use this function on any mailbox and where should I set them?

    Thanks for the replies in advance.




    Thursday, January 29, 2015 3:56 PM

Answers

  • As a test, can you try the following script (it uses Redemption)?

    set vSession = CreateObject("Redemption.RDOSession")
    vSession.MAPIOBJECT = Application.Session.MAPIOBJECT
    set vStore = vSession.GetStoreFromID(Application.ActiveExplorer.CurrentFolder.StoreId)
    for each vFolder in vStore.SearchRootFolder.Folders
      Debug.Print vFolder.Name
    next


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, January 29, 2015 8:44 PM

All replies

  • Hello Tommy,

    Try to use the GetSharedDefaultFolder method of the Namespace class instead. It returns a Folder object that represents the specified default folder for the specified user. This method is used in a delegation scenario, where one user has delegated access to another user for one or more of their default folders (for example, their shared Calendar folder).

    Thursday, January 29, 2015 4:16 PM
  • Thanks for your answer. I can get the default folder for the shared mailbox, but this folder object doesn't contain the search folders corresponding to the mailbox, because Outlook handle search folders differently.
    Do you have any ideas to get these search folders? 

    Thank you in advance.
    • Edited by ToMmY_hun Thursday, January 29, 2015 4:48 PM
    Thursday, January 29, 2015 4:43 PM
  • Do you see seach folders from a shared mailbox in Outlook? Can you reach them manually?
    Thursday, January 29, 2015 5:19 PM
  • Is delegate mailbox cached?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, January 29, 2015 5:49 PM
  • Do you see seach folders from a shared mailbox in Outlook? Can you reach them manually?

    Yes, search folders can be reached manually.

    Thursday, January 29, 2015 6:20 PM
  • As a test, can you try the following script (it uses Redemption)?

    set vSession = CreateObject("Redemption.RDOSession")
    vSession.MAPIOBJECT = Application.Session.MAPIOBJECT
    set vStore = vSession.GetStoreFromID(Application.ActiveExplorer.CurrentFolder.StoreId)
    for each vFolder in vStore.SearchRootFolder.Folders
      Debug.Print vFolder.Name
    next


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, January 29, 2015 8:44 PM
  • This method works a little bit slowly, but at least it works. :) If anyone have a better idea please share it. 

    Thank you for the answer. 
    Friday, January 30, 2015 10:06 AM
  • Is delegate mailbox cached ("Advanced | Download shared folders" checkbox in the Exchange account options)?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Friday, January 30, 2015 1:31 PM
  • If I enable the cache option search folders will disappear. I think this problem can not be solved effectively using this way.
    Friday, January 30, 2015 11:23 PM
  • So it is pretty much either Extended MAPI (C++ or Delphi) or Redemption (which wraps Extended MAPI)...

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Friday, January 30, 2015 11:37 PM