(Objective-C) Extract Files from MIME
Extract files from a MIME message. Note: This example requires Chilkat v11.0.0 or greater.
#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;
}
|