Internet Messaging Functions (IMAP) > Alphabetical List of Functions > imap_search


Example: imap_search Internet Messaging Functions (IMAP)

Searches for messages that match the search criteria.

int imap_search( char *transaction, char *key, char *param, char *saveto, ENDITEM, LAST );
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)"
saveto The name of the parameter to save message to."saveto=ParameterName"
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 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 global sessions. For multiple sessions, use the imap_search_ex function, which allows you to specify a session identifier.

To save the content of the message to a parameter, use the saveto parameter. You must specify the size of the buffer that holds the message with a call to imap_set_max_param_len_ex.

Return Values

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


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