Share this page

# imap_search_ex

Internet Messaging Functions (IMAP)

Searches for messages that match the search criteria, for a specific session.

    int imap_search_ex( IMAP *ppimap, char *transaction, char *key, char *param, ENDITEM, LAST );

ppimap | A session identifier.
transaction | A transaction name for this step in quotes. To avoid creating a transaction for this step, use a null string, "".
key | The Search Keys, in the following format: `"`Search=criteria`".` Note that the search is not case-sensitive.
param | A parameter in which to store the search results. Use the following format: `"SaveTo=`param1 (data)`"`
ENDITEM | A marker indicating the end of the data item list. Repeat the criteria, param, and ENDITEM arguments for each set of data that you fetch.
LAST | A marker indicating the end of the argument list.

The imap_search_ex function searches the mailbox for messages that match the search criteria. Search criteria may consist of one or more Search Keys.

This function is for use with multiple sessions. For global sessions, use the imap_search function, which leaves out the session identifier.

## Return Values

If this function succeeds, it returns LR_PASS. Otherwise, it returns LR_FAIL.

## Parameterization

All arguments of this function of the type char, can be parameterized with standard parameterization.

## Example

In the following example, the imap_search_ex function searches for messages that have the \\FLAG tag, that were modified since 1-FEB-1994, and contain Smith in the From field. It saves these messages to Param1.

        imap_search_ex(&imap1,"SearchForSmith",

            "Search=FLAGGED SINCE 1-FEB-1994 FROM \"Smith\"",

            "SaveTo=Param1",ENDITEM,

             LAST );

In the following example, the imap_search_ex function gets the UIDs.

    imap_search_ex(&imap1, "SearchMessages",
    	"Mode=UID",
    	"Search=ALL", // or any other search criteria
    	"SaveTo=search_res1", ENDITEM,
    	LAST);

Parse "search_res1" to get UIDs.

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: