To retrieve a preview for a message, the PREVIEW FETCH attribute is used when issuing a FETCH command.
The server returns a variable-length string that is the generated preview for that message. This string is intended to be viewed by the user as a contextual preview of the entire message and is not intended to be interpreted in any way by the client software.
Example: Retrieving preview information in a SELECTed mailbox.
C: A1 FETCH 1 (PREVIEW)
S: * 1 FETCH (PREVIEW "Preview text!")
S: A1 OK FETCH complete.
A server
SHOULD strive to generate the same string for a given message for each request. However, since previews are understood to be an approximation of the message data and not a canonical view of its contents, a client
MUST NOT assume that a message preview is immutable for a given message. This relaxed requirement permits a server to offer previews as an option without requiring potentially burdensome storage and/or processing requirements to guarantee immutability for a use case that does not require this strictness. For example, the underlying IMAP server may change due to a system software upgrade; an account's state information may be retained in the migration, but the new server may generate different preview text than the old server.
It is possible that the server has determined that no meaningful preview text can be generated for a particular message. Examples of this involve encrypted messages, content types the server does not support previews of, and other situations where the server is not able to extract information for a preview. In such cases, the server
MUST return a zero-length string. Clients
SHOULD NOT send another FETCH for a preview for such messages. (As discussed previously, preview data is not immutable, so there is chance that at some point in the future the server would be able to generate meaningful text. However, this scenario is expected to be rare, so a client should not continually send out requests to try to detect this infrequent occurrence.)
If the
Section 4.1 is used, the server
MAY return NIL for the preview response, indicating that preview generation could not be completed without causing undue delay. A server
MUST NOT return NIL to a FETCH PREVIEW request made without the LAZY modifier.
The generated preview text
MUST be treated as [
RFC 2046] media type data by the client.
The generated string
MUST NOT be content transfer encoded and
MUST be encoded in [
RFC 3629]. The server
SHOULD remove any formatting markup and do whatever processing might be useful in rendering the preview as plain text.
For purposes of this section, a "preview character" is defined as a single Universal Character Set (UCS) character encoded in UTF-8. Note: a single preview character may comprise multiple octets, so any buffers implemented to conform to the string limitations identified in this document should be sized to prevent possible overflow errors.
The server
SHOULD limit the length of the preview text to 200 preview characters. This length should provide sufficient data to generally support both various languages (and their different average word lengths) and diverse client display size requirements.
The server
MUST NOT output preview text longer than 256 preview characters.
If the preview is not generated based on the body content of the message, and the [
RFC 5255] is supported by the server, the preview text
SHOULD be generated according to the language rules that apply to human-readable text. For example, a message that consists of a single image MIME part has no human-readable text from which to generate preview information. Instead, the server may wish to output a description that the message contains an image and describe some attributes of the image, such as image format, size, and filename. This descriptive text is not a product of the message body itself but is rather auto-generated data by the server; it should thus use the rules defined for human-readable text described in the LANGUAGE extension (if supported on the server).