![]() |
Searching two string at a time in the Object of emails - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Indy (https://www.atozed.com/forums/forum-8.html) +--- Forum: Indy General Discussion (https://www.atozed.com/forums/forum-9.html) +--- Thread: Searching two string at a time in the Object of emails (/thread-2612.html) |
Searching two string at a time in the Object of emails - luigisic - 01-07-2022 Hello, with SearchMailBox is possible to search emails with some criteria. I need to search emails that Object contains the string "ACC: " and emails that Object contains the string "CON: ". Can i search both strings at a time? This code Code: SearchInfo.Date := 0; It seems not right because I dont find the emails. if i search only one string at a time i found the emails. Where I'm wrong? Thanks RE: Searching two string at a time in the Object of emails - rlebeau - 01-07-2022 (01-07-2022, 06:22 PM)luigisic Wrote: Can i search both strings at a time? When you specify multiple criteria to the IMAP SEARCH command, it returns the intersection (AND) of all matching criteria. Per RFC 3501 Section 6.4.4: Quote:When multiple keys are specified, the result is the intersection (AND function) of all the messages that match those keys. For example, the criteria DELETED FROM "SMITH" SINCE 1-Feb-1994 refers to all deleted messages from Smith that were placed in the mailbox since February 1, 1994. A search key can also be a parenthesized list of one or more search keys (e.g., for use with the OR and NOT keys). So, in your example, you are searching for emails that:
Which I suspect is probably not what you want. You probably want something more like this instead:
The SEARCH command has an OR <search-key1> <search-key2> search-key for that very purpose, so try this: Code: SetLength(SearchInfoArray, 4); RE: Searching two string at a time in the Object of emails - luigisic - 01-07-2022 (01-07-2022, 07:11 PM)rlebeau Wrote: Which I suspect is probably not what you want. You probably want something more like this instead: Yes, You are right. (01-07-2022, 07:11 PM)rlebeau Wrote: The SEARCH command has an OR <search-key1> <search-key2> search-key for that very purpose, so try this: This code work as I want. You are an irreplaceable resource ![]() Thanks |