Sample code for 30+ languages & platforms
Objective-C

Extract Files from MIME

See more MIME Examples

Extract files from a MIME message.

Chilkat Objective-C Downloads

Objective-C
#import <CkoMime.h>
#import <CkoStringTable.h>

BOOL success = NO;

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

CkoMime *mime = [[CkoMime alloc] init];

// Load a MIME document from a file:
// (.mht and .eml files contain MIME).
success = [mime LoadMimeFile: @"mst.mht"];
if (success == NO) {
    NSLog(@"%@",mime.LastErrorText);
    return;
}

CkoStringTable *st = [[CkoStringTable alloc] init];
success = [mime PartsToFiles: @"/temp/mimeParts" st: st];
if (success == NO) {
    NSLog(@"%@",mime.LastErrorText);
    return;
}

int n = [st.Count intValue];

// Display the paths of the files created:
int i = 0;
while (i < n) {
    NSLog(@"%@",[st StringAt: [NSNumber numberWithInt: i]]);
    i = i + 1;
}