Objective-C Requires Chilkat v11.0.0+
Objective-C
Choose the character set for an HTML email
See more Email Object Examples
Read a UTF-8 HTML file as Unicode, then set the charset Chilkat will use when writing the MIME text. The HTML file’s input encoding and the message’s output charset are separate choices. UTF-8 can represent names from multiple writing systems.
Chilkat Objective-C Downloads
#import <CkoEmail.h>
#import <CkoStringBuilder.h>
BOOL success = NO;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
CkoEmail *email = [[CkoEmail alloc] init];
email.From = @"Workshop team <events@example.com>";
success = [email AddTo: @"Alex Rivera" emailAddress: @"alex@example.net"];
if (success != YES) {
NSLog(@"%@",email.LastErrorText);
return;
}
email.Subject = @"Workshop registration";
CkoStringBuilder *html = [[CkoStringBuilder alloc] init];
success = [html LoadFile: @"newsletter.html" charset: @"utf-8"];
if (success != YES) {
NSLog(@"%@",@"Failed: html.LoadFile.");
return;
}
email.Charset = @"utf-8";
[email SetHtmlBody: [html GetAsString]];
success = [email SaveEml: @"newsletter.eml"];
if (success != YES) {
NSLog(@"%@",email.LastErrorText);
return;
}
NSLog(@"%@",@"Saved newsletter.eml.");