IPWorks OpenPGP 2020 Node.js Edition

Questions / Feedback?

SearchMailbox Method

Search selected mailbox for specified text.

Syntax

pimap.searchMailbox(searchCriteria, [callback])

Callback

The 'callback' parameter specifies a function which will be called when the operation completes (or an error is encountered). If the 'callback' parameter is not specified, then the method will block and will not return until the operation completes (or an error is encountered).

The callback for this method is defined as:

function(err){ }

'err' is the error that occurred. If there was no error, then 'err' is 'null'.

'err' has 2 properties which hold detailed information:

err.code
err.message

Remarks

This method searches the selected mailbox using the criteria specified in the SearchCriteria parameter. For every message matching the criteria, the FetchMessageInfo method is called and a MessageInfo event is fired.

The exact format of the search criteria is specified by the IMAP RFCs. The string consists of one or more search keys and their corresponding values (if any) separated by spaces, for example: "SINCE 1-Feb-1994 NOT FROM Smith".

Possible search keys include:

<message set>Messages with message sequence numbers corresponding to the specified message sequence number set
ALLAll messages in the mailbox - this is the default initial key for AND-ing.
ANSWEREDMessages with the \Answered flag set.
BCC <string>Messages that contain the specified string in the envelope structure's BCC field.
BEFORE <date>Messages whose internal date is earlier than the specified date.
BODY <string> Messages that contain the specified string in the body of the message.
CC <string> Messages that contain the specified string in the envelope structure's CC field.
DELETED Messages with the \Deleted flag set.
DRAFT Messages with the \Draft flag set.
FLAGGED Messages with the \Flagged flag set.
FROM <string> Messages that contain the specified string in the envelope structure's FROM field.
HEADER <field-name> <string> Messages that have a header with the specified field-name (as defined in [RFC-822]) and that contains the specified string in the [RFC-822] field-body.
KEYWORD <flag> Messages with the specified keyword set.
LARGER <n> Messages with an RFC822.SIZE larger than the specified number of octets.
NEW Messages that have the \Recent flag set but not the \Seen flag. This is functionally equivalent to "(RECENT UNSEEN)".
NOT <search-key> Messages that do not match the specified search key.
OLD Messages that do not have the \Recent flag set. This is functionally equivalent to "NOT RECENT" (as opposed to "NOT NEW").
ON <date> Messages whose internal date is within the specified date.
OR <search-key1> <search-key2> Messages that match either search key.
RECENT Messages that have the \Recent flag set.
SEEN Messages that have the \Seen flag set.
SENTBEFORE <date> Messages whose [RFC-822] Date: header is earlier than the specified date.
SENTON <date> Messages whose [RFC-822] Date: header is within the specified date.
SENTSINCE <date> Messages whose [RFC-822] Date: header is within or later than the specified date.
SINCE <date> Messages whose internal date is within or later than the specified date.
SMALLER <n> Messages with an RFC822.SIZE smaller than the specified number of octets.
SUBJECT <string> Messages that contain the specified string in the envelope structure's SUBJECT field.
TEXT <string> Messages that contain the specified string in the header or body of the message.
TO <string> Messages that contain the specified string in the envelope structure's TO field.
UID <message set> Messages with unique identifiers corresponding to the specified unique identifier set.
UNANSWERED Messages that do not have the \Answered flag set.
UNDELETED Messages that do not have the \Deleted flag set.
UNDRAFT Messages that do not have the \Draft flag set.
UNFLAGGED Messages that do not have the \Flagged flag set.
UNKEYWORD <flag> Messages that do not have the specified keyword set.
UNSEEN Messages that do not have the \Seen flag set.

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks OpenPGP 2020 Node.js Edition - Version 20.0 [Build 8249]