mimeEntityGetBody

SYNOPSIS

varbyte mimeEntityGetBody(mimeEntity entityOrReader[, varchar flags])

Parameters:

  • entityOrReader - A mimeEntity or mimeReader object

  • flags - An optional CSV list of flags:

    • "reparented" - Re-parent HTML if appropriate

Returns:

  • The decoded varbyte body of the entity


DESCRIPTION
The mimeEntityGetBody function returns the varbyte body of the given entity, with any transfer-encoding decoded. A varbyte value is returned instead of varchar in case the body is binary, e.g. an image.

If the optional "reparented" flag is given, then if the body is HTML and within a multipart/related entity tree, links within the HTML will be reparented with relatedfiles mode (here): all internal links (to other parts of the message) will be changed to their safe filenames (see mimeEntityGetSafeFilename, here), and all external links will be made absolute. Thus, if all the parts of the message have their reparented mimeEntityGetBody values written to their safe filenames in the same directory, inline images will be resolved when the reparented HTML is viewed in a web browser. Both cid: (content ID) and ordinary (content location e.g. http:) internal links are handled. Relative links whose base (absolute) URL cannot be established (i.e. missing Content-Location) will be made relative to the fictional URL thismessage:, per RFC 2557. This prevents their inadvertent access in the wrong context (e.g. relative to a display site).

Note: to make the reparented body "safe" - i.e. suppress any references to external images when viewed in a browser - the HTML can be further processed with the hideexternal mode (here) of <urlcp reparentmode>, with a local re-fetch of the body HTML.

The "reparented" flag has no effect if the body is not HTML, or if the entity is not within a multipart/related entity tree.


EXAMPLE

<$ret = (mimeEntityGetBody($reader))>
  Body: $ret


CAVEATS

SEE ALSO
mimeEntityGetSafeFilename, mimeEntityGetText


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.