Sample code for 30+ languages & platforms
Unicode C++

MIME Multipart Boundary and Preamble Properties

See more MIME Examples

Demonstrates the Boundary property, which gets or sets the raw boundary token of a multipart entity (without surrounding quotation marks), and UseMmDescription, which controls whether the conventional preamble text is emitted when serializing a multipart entity.

Background. A multipart boundary separates the constituent parts. Chilkat quotes the token automatically in the header when required. The preamble is ignored by MIME-aware readers and is off by default.

Chilkat Unicode C++ Downloads

Unicode C++
#include <CkMimeW.h>

void ChilkatSample(void)
    {
    bool success = false;

    CkMimeW mime;

    //  Create a multipart/mixed entity.
    success = mime.NewMultipartMixed();
    if (success == false) {
        wprintf(L"%s\n",mime.lastErrorText());
        return;
    }

    //  Boundary is the raw boundary token, without surrounding quotation marks.  Chilkat quotes it
    //  automatically in the serialized header when required.
    mime.put_Boundary(L"example-boundary");

    //  UseMmDescription controls whether the conventional preamble text
    //  "This is a multi-part message in MIME format." is emitted.  The default is false.
    mime.put_UseMmDescription(true);

    //  Add a simple part so the multipart has content.
    CkMimeW part;
    success = part.SetBodyFromPlainText(L"First part.");
    if (success == false) {
        wprintf(L"%s\n",part.lastErrorText());
        return;
    }

    success = mime.AppendPart(part);
    if (success == false) {
        wprintf(L"%s\n",mime.lastErrorText());
        return;
    }

    wprintf(L"Boundary = %s\n",mime.boundary());

    const wchar_t *mimeStr = mime.getMime();
    if (mime.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",mime.lastErrorText());
        return;
    }

    wprintf(L"%s\n",mimeStr);
    }