(Objective-C) Unpack HTML Email to Files
Unpacks an HTML email into an HTML file and related files (images and style sheets). The links within the HTML are updated to point to the files unpacked and saved to disk.
#import <CkoEmail.h>
#import <NSString.h>
CkoEmail *email = [[CkoEmail alloc] init];
BOOL success;
success = [email LoadEml: @"qa_data/eml/happyHour.eml"];
if (success != YES) {
NSLog(@"%@",email.LastErrorText);
return;
}
// Is this an HTML email?
if ([email HasHtmlBody] == YES) {
// Unpack the HTML to files. The image and css URLs
// in the HTML are modified to point to the files extracted to disk.
NSString *unpackDir = @"qa_output/emails";
NSString *partsSubdir = @"images";
NSString *htmlFilename = @"happyHour.html";
success = [email UnpackHtml: unpackDir htmlFilename: htmlFilename partsSubdir: partsSubdir];
if (success != YES) {
NSLog(@"%@",email.LastErrorText);
return;
}
NSLog(@"%@",@"Success.");
}
|