Name

Zarafa specific text functions — This section describes special functions used to handle texts of a mailbody.

Synopsis

string mapi_decompressrtf(string $compressedRTF);
string mapi_rtf2html(string $RTF);
string mapi_html2rtf(string $HTML);
string mapi_compressrtf(string $uncompressedRTF);

Details

mapi_decompressrtf ()

>string mapi_decompressrtf(string $compressedRTF)

Decompresses a compressed RTF stream from the PR_RTF_COMPRESSED property.

This function will decompress the RTF Body from a message and return the decompressed RTF.

$compressedRTF
A string with the compressed RTF information. This information can be retrieved with mapi_openproperty($message, PR_RTF_COMPRESSED)

Example 3.83. Decompress a RTF body

$rtf = mapi_openproperty($inbox, PR_RTF_COMPRESSED);

echo mapi_decompressrtf($rtf); // will echo the raw rtf data
		

mapi_rtf2html ()

string mapi_rtf2html(string $RTF)

Decodes the raw RTF data to readable HTML.

This function will read the embedded HTML from an RTF stream. When the RTF Stream is not of the embedded HTML RTF type the function will return false indicating that the body must be read as plaintext.

$RTF
A string with the raw RTF data. This data is usally the output from the mapi_decompressrtf function.

Example 3.84. Decoding RTF

$rtf = mapi_openproperty($inbox, PR_RTF_COMPRESSED);

echo mapi_rtf2html(mapi_decompressrtf($rtf));	// will echo the html data.
		

mapi_html2rtf ()

string mapi_html2rtf(string $HTML)

Encodes the HTML as RTF.

This function encodes the given HTML into an RTF document, which can subsequently be passed to mapi_compressrtf to be included in MAPI messages. The HTML is encoded so that when it is decoded, the exact HTML source is again readable.

$HTML
The HTML data to be encoded into RTF.

Example 3.85. Encoding HTML

echo mapi_html2rtf("<HTML><p>This is a test</HTML>");
		

mapi_compressrtf ()

Compresses an uncompressed RTF stream for the PR_RTF_COMPRESSED property.

This function will compress the RTF Body for a message and return the compressed RTF.

string mapi_compressrtf(string $uncompressedRTF);
$uncompressedRTF
A string with the uncompressed RTF information. This information can be stored using mapi_openpropertystream($message, PR_RTF_COMPRESSED), mapi_stream_write($stream, $compressedRTF) etc.

Example 3.86. Compress an RTF body

$rtf = mapi_openproperty($inbox, PR_RTF_COMPRESSED);

$decompressedRTF = mapi_decompressrtf($rtf);
// will echo the raw rtf data, uncompressed
echo $decompressedRTF;

// will echo compressed RTF data, usable for streaming (back) to PR_RTF_COMPRESSED
echo mapi_compressrtf($decompressedRTF);