Sample code for 30+ languages & platforms
Unicode C

Extract Files from MIME

See more MIME Examples

Extract files from a MIME message.

Chilkat Unicode C Downloads

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

void ChilkatSample(void)
    {
    BOOL success;
    HCkMimeW mime;
    HCkStringTableW st;
    int n;
    int i;

    success = FALSE;

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    mime = CkMimeW_Create();

    // Load a MIME document from a file:
    // (.mht and .eml files contain MIME).
    success = CkMimeW_LoadMimeFile(mime,L"mst.mht");
    if (success == FALSE) {
        wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
        CkMimeW_Dispose(mime);
        return;
    }

    st = CkStringTableW_Create();
    success = CkMimeW_PartsToFiles(mime,L"/temp/mimeParts",st);
    if (success == FALSE) {
        wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
        CkMimeW_Dispose(mime);
        CkStringTableW_Dispose(st);
        return;
    }

    n = CkStringTableW_getCount(st);

    // Display the paths of the files created:
    i = 0;
    while (i < n) {
        wprintf(L"%s\n",CkStringTableW_stringAt(st,i));
        i = i + 1;
    }



    CkMimeW_Dispose(mime);
    CkStringTableW_Dispose(st);

    }