Sample code for 30+ languages & platforms
Unicode C

Load MIME from BinData

See more MIME Examples

Demonstrates the Chilkat Mime.LoadMimeBd method, which parses complete MIME bytes from a BinData and replaces the current MIME. The only argument is the BinData.

Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.

Background: This is the safest loader because it works on raw bytes: MIME can carry 8-bit content and even embedded NUL bytes that a text string would mangle, so loading from a BinData preserves the message exactly. Prefer it whenever the input is binary or of uncertain encoding — a downloaded message, a file read as bytes — over the string-based loaders.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkBinDataW.h>
#include <C_CkMimeW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkBinDataW bd;
    HCkMimeW mime;

    success = FALSE;

    //  Demonstrates the Mime.LoadMimeBd method, which parses complete MIME bytes from a BinData and
    //  replaces the current MIME.  The only argument is the BinData.  This is the preferred loader
    //  when the MIME may contain arbitrary 8-bit or embedded NUL bytes.

    bd = CkBinDataW_Create();
    success = CkBinDataW_LoadFile(bd,L"qa_data/message.eml");
    if (success == FALSE) {
        wprintf(L"%s\n",CkBinDataW_lastErrorText(bd));
        CkBinDataW_Dispose(bd);
        return;
    }

    mime = CkMimeW_Create();
    success = CkMimeW_LoadMimeBd(mime,bd);
    if (success == FALSE) {
        wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
        CkBinDataW_Dispose(bd);
        CkMimeW_Dispose(mime);
        return;
    }

    wprintf(L"Content-Type: %s\n",CkMimeW_contentType(mime));


    CkBinDataW_Dispose(bd);
    CkMimeW_Dispose(mime);

    }