Forum Discussion

Jim_Ma's avatar
Jim_Ma
Level 2
12 years ago

How to search mails from custom folders via EV Search API?

I'm using EV search api to search emails. However, I can only search the mails from system folders such as "Inbox", "Sent Items", etc. Our customer created custom folders such as inbox/firm, inbox/helpdesk. I cannot search the mails under those custom folders. Any idea?

This is how I get my achives:

            IArchives archivesRead = (IArchives)cmAPI.Archives;
            archivesRead.Computer = "192.168.24.26";
            archivesRead.Permissions = EV_STG_API_PERMISSIONS_TYPE.PERMISSIONS_SEARCH;
            archivesRead.ArchiveTypes = (int)EV_STG_API_ARCHIVE_TYPE.ARCHIVE_TYPE_MAILBOX;
            archivesRead.Get();

This is how I use the search api:

                ISearchQuery2 query = (ISearchQuery2)new SearchQuery();
                IIndexSearch2 search = (IIndexSearch2)new IndexSearch2();

                search.SelectArchive(archiveId);
                query.AddTerm("rtea", "xx@dd.com", 0);
                //query.AddOp((int)ESearchQueryOperators.ESQand, (int)ESearchOperatorScope.ESQdefault);
                ISearchResults2 results = (ISearchResults2)search.Search(query.Query, 1, 10000, "");

3 Replies

  • Do you have emails archived in those custom folders? And are they indexed properly?

    It could be realted to  IIndexSearch2 :: HasFolders

    This property indicates whether the currently selected archive contains a folder structure.

    search.SelectArchive("ArchiveID");

    //do something

    if (search.HasFolders == true)

    {

    //do something

  • Yes. There're several emails in those custom folders. And when I select one of these emails in Outlook, there's a status bar float on the top of message body says it has been archived. 

    I haven't tried HasFolders. Will let you know the result later. Thanks.

  • Hi, I checked that search.HasFolders is 'true'. I think it only indicates we have system folder structures like "index", "sent items". However, I don't know if the custom folders can be recognized by HasFolders value. Still, I'm not able to find any emails in the custom folders by using following code: ISearchResults2 results = (ISearchResults2)search.Search(query.Query, 1, 10000, "");