Sample code for 30+ languages & platforms
Xbase++

Serialize MIME to a StringBuilder

See more MIME Examples

Demonstrates the Chilkat Mime.GetMimeSb method, which serializes the complete MIME entity and appends it to a StringBuilder. The only argument is the StringBuilder; existing content is preserved.

Background: Serializing into a StringBuilder avoids creating a new string and is convenient when you are accumulating output or building a larger document. Because it appends, you can assemble several pieces in one buffer. As with GetMime, use the BinData form for content with arbitrary binary bytes.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oMime
LOCAL oSb

nSuccess := 0

//  Demonstrates the Mime.GetMimeSb method, which serializes the complete MIME entity and appends
//  it to a StringBuilder.  The only argument is the StringBuilder.

oMime := CreateObject("Chilkat.Mime")

nSuccess := oMime:SetBodyFromPlainText("Hello, this is the message body.")
IF (nSuccess == 0)
    ? oMime:LastErrorText
    oMime:destroy()
    RETURN
ENDIF

//  Append the serialized MIME to a StringBuilder.  Existing content is preserved.
oSb := CreateObject("Chilkat.StringBuilder")
nSuccess := oMime:GetMimeSb(oSb)
IF (nSuccess == 0)
    ? oMime:LastErrorText
    oMime:destroy()
    oSb:destroy()
    RETURN
ENDIF

? oSb:GetAsString()

oMime:destroy()
oSb:destroy()