Archived Forum Post

Index of archived forum posts

Question:

imap.search not working unless its ALL

Dec 08 '16 at 07:44

Hi

New to ChilKat but hoping someone can help - I am probably doing something dumb

If I use imap.search with "ALL" as a criteria then it works fine and I can loop through the messageset and get all the info for the various emails. If however I try and be specific using SUBJECT or HEADER <field> or TEXT (or anything other than ALL) then it returns 0 messages - so in ALL I can show the subject (for example one email has a subject of Hello and I see that in the returned messageset for ALL) but if i then search SUBJECT Hello it returns 0 messages (and any other criteria does the same) - any help or thoughts appreciated! - its 9.5.0 32 bit via VBS - working ALL, non working Hello and lasterror shown below.

Not Working searchkey = "SUBJECT Hello"

          Set messageSet = imap.Search(searchkey,1)

Working searchkey = "ALL"

         Set messageSet = imap.Search(searchkey,1)
**ChilkatLog:**
  Search:
    DllDate: Mar 11 2014
    ChilkatVersion: 9.5.0.18
    UnlockPrefix: Anything for 30-day trial
    Username: SV-DLL-TRANSD02:bot_dmy
    Architecture: Little Endian; 32-bit
    Language: ActiveX
    VerboseLogging: 0
    criteria: SUBJECT Hello
    criteriaUtf8QP: SUBJECT Hello
    connectedTo: 130.4.111.90
    selectedMailbox: Inbox
    bUid: 1
    Command: aaad UID SEARCH SUBJECT Hello
    numMessages: 0
    Success.
  --Search
--ChilkatLog

Accepted Answer

The emails are stored on the IMAP server, and therefore it's the IMAP server that performs the actual search specified by the search criteria in the SEARCH command. An IMAP client, such as Chilkat, doesn't do the actual searching. It's simply sending the SEARCH command (with a criteria string), the IMAP server does the search, and returns the results.

The Chilkat Imap.Search method passes the search criteria argument unmodified to the IMAP server. The format/syntax of the criteria is specified by RFC 3501 (Section 6.4.4) -- See https://tools.ietf.org/html/rfc3501#section-6.4.4

Different IMAP servers may support different subsets of the SEARCH criteria specification. Also, it depends on the IMAP server as to what email content is actually indexed. In this case, the IMAP server is saying "Database is not full text indexed".

There's nothing that can be done from the client-side to make this particular search work. It's because the client simply sends the command and receives the IMAP server's results.


Answer

Hi - Thanks for the reply.

I have downloaded and tried the latest version - the same result I am afraid (although it now returns as failed rather than 0 messages) - log below. I have also tried for example setting it as "SUBJECT ""Hello""" in case it is to do with quoting but the same result (and the same with message-id etc as well).

ChilkatLog:
  Search:
    DllDate: Nov 12 2016
    ChilkatVersion: 9.5.0.64
    UnlockPrefix: ADLTLLYIMAPMAILQ
    Architecture: Little Endian; 32-bit
    Language: ActiveX
    VerboseLogging: 0
    criteria: SUBJECT "Hello"
    criteriaUtf8QP: SUBJECT "Hello"
    connectedTo: 130.4.111.90
    selectedMailbox: Inbox
    bUid: 1
    Command: aaad UID SEARCH SUBJECT "Hello"
    Failed.
  --Search
--ChilkatLog

Answer

UPDATE (and further question)

Turning on verbose logging gives me more (as below) - namely it responds with NO SEARCH Database is not full text indexed. What database is it talking about here - the mail server database? Are we saying that unless it is FTI it cannot perform a search?

ChilkatLog:
  Search:
    DllDate: Nov 12 2016
    ChilkatVersion: 9.5.0.64
    UnlockPrefix: ADLTLLYIMAPMAILQ
    Architecture: Little Endian; 32-bit
    Language: ActiveX
    VerboseLogging: 1
    criteria: SUBJECT "Hello"
    criteriaUtf8QP: SUBJECT "Hello"
    connectedTo: 130.4.111.90
    selectedMailbox: Inbox
    bUid: 1
    Command: aaad UID SEARCH SUBJECT "Hello"
    ImapCmdSent: aaad UID SEARCH SUBJECT "Hello"
    getCompleteResponse:
      ImapCmdResp: aaad NO SEARCH Database is not full text indexed
    --getCompleteResponse
    Failed.
  --Search
--ChilkatLog

Answer

That's a pretty old version of the library (from 2014). I recommend trying with the latest version and see if the problem persists.

If not, please repost the log in <pre></pre> tags in case there is more information generated in the newer library.