(Objective-C) Access Attached Message (Embedded Email)
How to access an email embedded within another email (i.e. an attached message). Note: This example requires Chilkat v11.0.0 or greater.
#import <CkoEmail.h>
BOOL success = NO;
CkoEmail *email = [[CkoEmail alloc] init];
// Load an email from a .eml
success = [email LoadEml: @"embeddedEmail.eml"];
if (success == NO) {
NSLog(@"%@",email.LastErrorText);
return;
}
// Display how many attached emails are embedded within
// this one:
int numAttached = [email.NumAttachedMessages intValue];
NSLog(@"%@%d",@"numAttached = ",numAttached);
// Get the 1st attached message.
CkoEmail *email2 = [[CkoEmail alloc] init];
success = [email GetAttachedEmail: [NSNumber numberWithInt: 0] email: email2];
if (success == YES) {
// Display the subject, From, and a header field...
NSLog(@"%@",email2.Subject);
NSLog(@"%@",email2.From);
NSLog(@"%@",[email2 GetHeaderField: @"X-SOMETHING"]);
}
|