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


Example: imap_fetch_ex Internet Messaging Functions (IMAP)

Retrieves data associated with mailbox messages, for a specific session.

int imap_fetch_ex( IMAP *ppimap, char *transaction, char *mode, char *message, char *saveto, 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, "".
mode The fetch mode in the following format:
message The messages whose data you want to fetch and the data. The data can be any information associated with the message, such as UID, FLAGS, RFC822.SIZE, RFC822.HEADER, etc. "Fetch=begin_msg:end_msg (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 option and ENDITEM arguments for each set of data that you fetch.
LAST A marker indicating the end of the argument list.

The imap_fetch_ex function retrieves data associated with mailbox messages, for a specific session. You can request the value of any message data including flags, headers, and message IDs.

This function is for use with multiple sessions. For global sessions, use the imap_fetch function, which leaves out the 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. See Example: imap_fetch_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.