locked
AdvancedSearch + GetSpecialFolder = Run time Error 8000ffff ? RRS feed

  • Question

  • Is it possible to use "GetSpecialFolder " as a Scope for AdvancedSearch ?

    I'm getting Error 8000ffff, when I try to do it: pic1,pic2.

    The code:

    Sub TaskSearchFolder()


        Set MyOutlookApplication = Outlook.Application
        SearchSubFolders = True
        Set MapiNamespace = Application.GetNamespace("MAPI")
            
        Dim DefaultTasksFolder As Folder
        Set DefaultTasksFolder = MapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks)
            
        Dim DefaultStore As Outlook.Store
        Set DefaultStore = DefaultTasksFolder.Store
        
        Set ToDoFolder = DefaultStore.GetSpecialFolder(Outlook.OlSpecialFolders.olSpecialFolderAllTasks)
            
        
        Scope = "'" & ToDoFolder.FolderPath & "'"
        'Scope = "'" & DefaultTasksFolder.FolderPath & "'"
        
        Debug.Print "Scope = " & Scope
            
        MyFilter = """http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/811c000b"" <> 1"
        
        Set Search = MyOutlookApplication.AdvancedSearch(Scope, MyFilter, SearchSubFolders)
        ResultsFolderName = "AllTasks_test4"
        Set ResultsFolder = Search.Save(ResultsFolderName)


    End Sub

    The same code works OK when I use

    Scope = "'" & DefaultTasksFolder.FolderPath & "'"

    instead of

    Scope = "'" & ToDoFolder.FolderPath & "'"

    .

    Friday, January 4, 2013 1:16 PM

Answers

  • Hi i3v,

    I think that is out of the ability of VBA. However, it might possible via MAPI C++ program.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by i3v Tuesday, January 8, 2013 2:00 PM
    Tuesday, January 8, 2013 6:13 AM

All replies

  • Hi i3V,

    Thanks for posting in the MSDN Forum.

    I think that variable "DefaultTasksFolder" and "ToDoFolder" in you code will reference different folder instance. The DefaultTasksFolder will reference the folder for the tasks folder of "DefaultStore". And "ToDoFolder" will reference all of the item which have flag in your "DefaultStore"

    Have a good day,

    Tom 


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 7, 2013 6:44 AM
  • i think TodoFolder is already a search folder, so what you want to achieve is making search folders based on search folders, which i do not think is supported.
    Monday, January 7, 2013 11:29 AM
  • Hi Tom ,

    thanks for your reply!

    I think that variable "DefaultTasksFolder" and "ToDoFolder" in you code will reference different folder instance.

    Sure... I used those "DefaultTasksFolder" only to test that in the whole my code is working (for a regular folder)...


    • Edited by i3v Monday, January 7, 2013 3:56 PM
    Monday, January 7, 2013 3:35 PM
  • Hello DamianD!

    i think TodoFolder is already a search folder,
    Actualy, it's a 3rd kind of folders (in addition to "regular" and "search" folders). The major difference comes from that fact that "ToDo list" might contain flagged items from several Outlook Data Files, while Search Folder Scope is always limited to a single data file.

    It looks like it's not supported, yep (sigh) ,although there's nothing about it in Documentation, and that's the point.

    I think, this should be mentioned, so, firstly, I've started this topic, just to be sure. And now, I've left a
    "Comunity Addition" there (it looks like they are pre-moderated at least,so, it's still not visible).



    By the way, is it possible to "create a copy" of "ToDo list" folder?

    (The aim is to set different filters on them).

    There's usually two copies, one in the Tasks Module, on on in the ToDo Bar in Mail Module.

    Monday, January 7, 2013 3:55 PM
  • Hi i3v,

    I think that is out of the ability of VBA. However, it might possible via MAPI C++ program.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by i3v Tuesday, January 8, 2013 2:00 PM
    Tuesday, January 8, 2013 6:13 AM
  • OK, thanks for your hint...
    Tuesday, January 8, 2013 2:00 PM