none
Redemption Search Folder Issue RRS feed

  • Question

  • I am trying to add an RDO search folder in my fullmetalstobber@gmail.com profile using the following code.

     
    RDOSession session = new RDOSession();
    session.MAPIOBJECT = Singleton.Instance.GetApp().Session.MAPIOBJECT;
    RDOStore DefaultStore = session.Stores.DefaultStore;
             
    RDOFolder SearchRootFolder = session.GetFolderFromPath("\\\\fullmetalstobber@gmail.com");
    
    RDOSearchFolder NewSearchFolder = SearchRootFolder.Folders.AddSearchFolder("NEWFOLDER");
                
    NewSearchFolder.SearchCriteria.AsSQL = "Subject LIKE '%facebook%'";
                NewSearchFolder.SearchContainers.Add(session.GetFolderFromPath("\\\\fullmetalstobber@gmail.com\\Inbox"));
                         
    NewSearchFolder.IsRecursiveSearch = true;
    NewSearchFolder.IsForegroundSearch = false;
    NewSearchFolder.Start();
    But I am getting the following exception.

    Error in IMAPIFolder.SetSearchCriteria: MAPI_E_EXTENDED_ERROR
    ulVersion: 0
    Component: Outlook Data File
    ulLowLevelError: 0
    ulContext: 269025537

    I am assuming that it has to do with something in session using Outlook Data File instead of fullemtalstobber@gmail.com, but I am extremely new to outlook programming, and don't know how I would change my application to use a different store(I don't know if I am using the word store properly). Any input? Thank you so much.

    Wednesday, May 8, 2013 1:34 AM

Answers

  • I resolved the issue. I am just putting folders inside of the Inbox, and placing the search folders in those sub folders. Thank you for all the help!
    Wednesday, May 8, 2013 8:15 PM

All replies

  • What kind of store is it? PST? IMAP4? Google Apps?

    Is the store in question the default one?

    What is you replace

    RDOFolder SearchRootFolder = session.GetFolderFromPath("\\\\fullmetalstobber@gmail.com");

    with

    RDOFolder SearchRootFolder = DefaultStore.IPMRootFolder;

    and

    NewSearchFolder.SearchContainers.Add(session.GetFolderFromPath(\\\\fullmetalstobber@gmail.com\\Inbox));

    with

    NewSearchFolder.SearchContainers.Add(DefaultStore.IPMRootFolder.Folders["Inbox"]);


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

    Wednesday, May 8, 2013 5:50 AM
  • I no longer get an exception, however, the search folder that is created doesn't have any emails in it, and the path of the IPMRootFolder is "\\\\Outlook Data File\\Inbox". All of my emails are in "\\\\fullmetalstobber@gmail.com\\Inbox"

    However, even when I put emails into Outlook Data File\\Inbox, no emails are found when I click on the search folder. I cannot figure out why my search folders never return any emails. Even when I create a serch folder manually in Outlook, it won't find any emails from the Outlook Data File\\Inbox folder. It does find emails if I create a search folder in the fullmetalstobber@gmail.com account though(In the left panel there is a Outlook Data File dropdown and fullmetalstobber@gmail.com dropdown is what I am referring too). How can I do what you just said but for the fullmetalstobber account without getting an exception? Any ideas? Thank you very much.


    • Edited by FlexSquad Wednesday, May 8, 2013 6:42 AM
    Wednesday, May 8, 2013 6:36 AM
  • I have made some progress. The following code successfully inserts a search folder INSIDE the main inbox, and it displays items. The problem is, I cannot put the folder ANYWHERE else, or it throws the previous exception.

     I need to be able to have the search folder saved to other areas.

      RDOSession session = new RDOSession();
                session.MAPIOBJECT = Singleton.Instance.GetApp().Session.MAPIOBJECT;
                RDOStore DefaultStore = session.Stores.DefaultStore;         
                RDOFolder SearchRootFolder = session.Stores[2].GetDefaultFolder(rdoDefaultFolders.olFolderInbox);//WORKS
           
                RDOSearchFolder NewSearchFolder = SearchRootFolder.Folders.AddSearchFolder(txtProjectName.Text);             
                NewSearchFolder.SearchCriteria.AsSQL = "Subject LIKE '%newegg%'"; 
                NewSearchFolder.SearchContainers.Add(session.Stores[2].GetDefaultFolder(rdoDefaultFolders.olFolderInbox));        
                NewSearchFolder.IsRecursiveSearch = true;
                NewSearchFolder.IsForegroundSearch = true;
                NewSearchFolder.Start();


    Also, if I use the path ""\\\\fullmetalstobber@gmail.com\\Inbox" directly, I get the exception, but if I use NewSearchFolder.SearchContainers.Add(session.Stores[2].GetDefaultFolder(rdoDefaultFolders.olFolderInbox));

    it works, even though both have the same path. Any ideas?

    • Edited by FlexSquad Wednesday, May 8, 2013 9:57 AM
    Wednesday, May 8, 2013 8:36 AM
  • Search folders cannot spawn across multiple stores. The search folder and the folders that it searches in must all be in the same store.


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

    Wednesday, May 8, 2013 2:11 PM
  • Isn't that what I am doing now? I just need the search folder to be in a different folder in the same store, but am having issues with this. And the main thing is, I don't understand why this works 

    "  RDOFolder SearchRootFolder = session.Stores[2].GetDefaultFolder(rdoDefaultFolders.olFolderInbox);//WORKS

    and this doesn't

     Folder f = Singleton.Instance.GetFolder("\\\\fullmetalstobber@gmail.com\\Inbox");

      NewSearchFolder.SearchContainers.Add(session.Stores[2].GetFolderFromID(f.EntryID));     

    They are both pointing to the same area.

    • Edited by FlexSquad Wednesday, May 8, 2013 4:07 PM
    Wednesday, May 8, 2013 4:02 PM
  • Are you sure you end up with the same store?

    What is your full code that does not work?


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

    Wednesday, May 8, 2013 4:45 PM
  • I resolved the issue. I am just putting folders inside of the Inbox, and placing the search folders in those sub folders. Thank you for all the help!
    Wednesday, May 8, 2013 8:15 PM