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#
bool success = false;

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

Chilkat.Mime mime = new Chilkat.Mime();

// Load a MIME document from a file:
// (.mht and .eml files contain MIME).
success = mime.LoadMimeFile("mst.mht");
if (success == false) {
    Debug.WriteLine(mime.LastErrorText);
    return;
}

Chilkat.StringTable st = new Chilkat.StringTable();
success = mime.PartsToFiles("/temp/mimeParts",st);
if (success == false) {
    Debug.WriteLine(mime.LastErrorText);
    return;
}

int n = st.Count;

// Display the paths of the files created:
int i = 0;
while (i < n) {
    Debug.WriteLine(st.StringAt(i));
    i = i + 1;
}