(Objective-C) Transition from MailMan.LoadXmlEmail to Email.SetFromXmlText
Provides instructions for replacing deprecated LoadXmlEmail method calls with Email.SetFromXmlText. Note: This example requires Chilkat v11.0.0 or greater.
#import <CkoMailMan.h>
#import <NSString.h>
#import <CkoEmail.h>
#import <CkoStringBuilder.h>
CkoMailMan *mailman = [[CkoMailMan alloc] init];
// ...
// ...
NSString *xmlFilePath = @"c:/test/example.xml";
// ------------------------------------------------------------------------
// The LoadXmlEmail method is deprecated:
CkoEmail *emailObj = [mailman LoadXmlEmail: xmlFilePath];
if (mailman.LastMethodSuccess == NO) {
NSLog(@"%@",mailman.LastErrorText);
return;
}
// ...
// ...
// ------------------------------------------------------------------------
// Do the equivalent using Email.SetFromXmlText.
CkoStringBuilder *sb = [[CkoStringBuilder alloc] init];
BOOL success = [sb LoadFile: xmlFilePath charset: @"utf-8"];
if (success == NO) {
NSLog(@"%@",sb.LastErrorText);
return;
}
CkoEmail *email = [[CkoEmail alloc] init];
success = [email SetFromXmlText: [sb GetAsString]];
if (success == NO) {
NSLog(@"%@",email.LastErrorText);
return;
}
|