Objective-C Requires Chilkat v11.0.0+
Objective-C
Set a MIME header on one attachment
See more Email Object Examples
Add a file using the content type required by the receiving application. Set Content-Description on the newly added MIME part and read it back from that part. The message-level headers have a separate collection.
Chilkat Objective-C Downloads
#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.Body = @"Attached is the requested data file.";
success = [email AddFileAttachment2: @"sample.hpm" contentType: @"application/x-hprimnet"];
if (success != YES) {
NSLog(@"%@",email.LastErrorText);
return;
}
int index = [email.NumAttachments intValue] - 1;
[email AddAttachmentHeader: [NSNumber numberWithInt: index] fieldName: @"Content-Description" fieldValue: @"HPM/3.0"];
NSLog(@"%@",[email GetAttachmentHeader: [NSNumber numberWithInt: index] fieldName: @"Content-Description"]);
success = [email SaveEml: @"described-attachment.eml"];
if (success != YES) {
NSLog(@"%@",email.LastErrorText);
return;
}
NSLog(@"%@",@"Saved described-attachment.eml.");