Sample code for 30+ languages & platforms
C++

Extract Files from MIME

See more MIME Examples

Extract files from a MIME message.

Chilkat C++ Downloads

C++
#include <CkMime.h>
#include <CkStringTable.h>

void ChilkatSample(void)
    {
    bool success = false;

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

    CkMime mime;

    // Load a MIME document from a file:
    // (.mht and .eml files contain MIME).
    success = mime.LoadMimeFile("mst.mht");
    if (success == false) {
        std::cout << mime.lastErrorText() << "\r\n";
        return;
    }

    CkStringTable st;
    success = mime.PartsToFiles("/temp/mimeParts",st);
    if (success == false) {
        std::cout << mime.lastErrorText() << "\r\n";
        return;
    }

    int n = st.get_Count();

    // Display the paths of the files created:
    int i = 0;
    while (i < n) {
        std::cout << st.stringAt(i) << "\r\n";
        i = i + 1;
    }
    }