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

Convert image data URLs to related MIME parts

See more Email Object Examples

Start with HTML that contains image bytes in a data URL. Convert it to conventional CID references and inspect the resulting related-item count before saving.

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 = @"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";
[email SetHtmlBody: @"<html><body><p>Registration confirmed.</p><img src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==\" alt=\"Mark\"></body></html>"];
success = [email ConvertInlineImages];
if (success != YES) {
    NSLog(@"%@",email.LastErrorText);
    return;
}

NSLog(@"%@%d",@"Related images: ",[email.NumRelatedItems intValue]);
NSLog(@"%@",[email GetHtmlBody]);

success = [email SaveEml: @"related-images.eml"];
if (success != YES) {
    NSLog(@"%@",email.LastErrorText);
    return;
}

NSLog(@"%@",@"Saved related-images.eml.");