Encode the Data
If the message is 7-bit ASCII text or the transport protocol preserves binary messages, it’s most efficient to use an identity encoding – an encoding that describes the data but does not alter the data. Otherwise, the best encoding depends on the data.
*If the transport protocol preserves binary data (for example, HTTP), then do not encode the message. Use an identity transfer encoding that describes the data:
*Use 7bit for text that contains only ASCII characters 0-127.
*Use 8bit for other text messages.
*Use binary for binary data.
*If the data contains only 7-bit ASCII text with lines less than 76 characters, do not encode the content. Use a Content-Transfer-Encoding of 7bit. This is the default encoding, so in this case, the part does not require a Content-Transfer-Encoding header.
*Otherwise, encode the data:
*Use quoted-printable encoding for text that is mostly 7-bit ASCII characters.
*Use base64 encoding for binary data or text that is mostly 8-bit characters.
Notice that base 64 encoding is the only safe choice for transmitting binary data over a protocol that does not preserve binary data, such as SMTP.
For text messages, the best encoding depends on the number of 8-bit characters. Quoted-printable encoding preserves 7-bit ASCII characters, while base 64 more efficiently encodes 8-bit characters. The practical result is that base 64 encoding is a good choice for text with a relatively large number of 8-bit characters, whereas quoted-printable encoding produces shorter, mostly human-readable messages for text that contains mostly 7-bit characters.
Convert data to canonical form before encoding the data (see Convert Text to Canonical Form ). To encode the data, use the static encode() function from RWMimeUtils. For example, to encode binary data using the base64 encoding:
 
RWCString binaryData;
 
// ... fill binaryData with the binary data
 
RWCString encoded = RWMimeUtils::encode(binaryData,
RWMimeUtils::Base64);
Encodings are discussed in detail in Transfer Encodings.