Sample code for 30+ languages & platforms
Objective-C

Parsing a Multipart/Digest Email

See more Email Object Examples

This example demonstrates how to parse a multipart/digest email. An email parsed by this sample could have a MIME structure as follows:
multipart/mixed
    text/plain
    text/plain
    multipart/digest
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
        message/rfc822
    text/plain

Chilkat Objective-C Downloads

Objective-C
#import <NSString.h>
#import <CkoEmail.h>

BOOL success = NO;

NSString *emlPath = @"qa_data/eml/multipart_digest.eml";

CkoEmail *email = [[CkoEmail alloc] init];

// For this example, we'll load the email from a .eml.
// The email could alternatively be loaded as a result of downloading from an IMAP or POP3 server..

success = [email LoadEml: emlPath];
if (success == NO) {
    NSLog(@"%@",email.LastErrorText);
    return;
}

int numDigests = [email.NumDigests intValue];
NSLog(@"%@%d",@"num digests = ",numDigests);

CkoEmail *eDigest = [[CkoEmail alloc] init];
int i = 0;
while (i < numDigests) {
    [email GetDigestEmail: [NSNumber numberWithInt: i] email: eDigest];
    NSLog(@"%d%@%@%@%@",i,@":",eDigest.FromAddress,@", ",eDigest.Subject);
    NSString *m = [eDigest GetHeaderField: @"Message"];
    if (eDigest.LastMethodSuccess == YES) {
        NSLog(@"%@%@",@"    Message = ",m);
    }

    i = i + 1;
}