Sample code for 30+ languages & platforms
PHP ActiveX

Extract Files from MIME

See more MIME Examples

Extract files from a MIME message.

Chilkat PHP ActiveX Downloads

PHP ActiveX
<?php

$success = 0;

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

$mime = new COM("Chilkat.Mime");

// Load a MIME document from a file:
// (.mht and .eml files contain MIME).
$success = $mime->LoadMimeFile('mst.mht');
if ($success == 0) {
    print $mime->LastErrorText . "\n";
    exit;
}

$st = new COM("Chilkat.StringTable");
$success = $mime->PartsToFiles('/temp/mimeParts',$st);
if ($success == 0) {
    print $mime->LastErrorText . "\n";
    exit;
}

$n = $st->Count;

// Display the paths of the files created:
$i = 0;
while ($i < $n) {
    print $st->stringAt($i) . "\n";
    $i = $i + 1;
}


?>