Sample code for 30+ languages & platforms
Objective-C Requires Chilkat v11.0.0+

Create, save, and reopen a plain-text email

See more Email Object Examples

Set the sender, recipient, subject, and plain-text body. Save the result as an EML file, then open it in a second Email object and read its contents.

Chilkat Objective-C Downloads

Objective-C
#import <CkoEmail.h>

BOOL success = NO;

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

CkoEmail *email = [[CkoEmail alloc] init];
email.From = @"Sam Lee <sam@example.com>";
success = [email AddTo: @"Alex Rivera" emailAddress: @"alex@example.net"];
if (success != YES) {
    NSLog(@"%@",email.LastErrorText);
    return;
}

email.Subject = @"Hello";
email.Body = @"This is a plain-text message.";
success = [email SaveEml: @"message.eml"];
if (success != YES) {
    NSLog(@"%@",email.LastErrorText);
    return;
}

CkoEmail *received = [[CkoEmail alloc] init];
success = [received LoadEml: @"message.eml"];
if (success != YES) {
    NSLog(@"%@",received.LastErrorText);
    return;
}

NSLog(@"%@",received.From);
NSLog(@"%@",received.Subject);
NSLog(@"%@",[received GetPlainTextBody]);