Java
Java
Transition from MailMan.LoadXmlEmail to Email.SetFromXmlText
Provides instructions for replacing deprecated LoadXmlEmail method calls with Email.SetFromXmlText.Chilkat Java Downloads
import com.chilkatsoft.*;
public class ChilkatExample {
static {
try {
System.loadLibrary("chilkat");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
boolean success = false;
CkMailMan mailman = new CkMailMan();
// ...
// ...
String xmlFilePath = "c:/test/example.xml";
// ------------------------------------------------------------------------
// The LoadXmlEmail method is deprecated:
CkEmail emailObj = mailman.LoadXmlEmail(xmlFilePath);
if (mailman.get_LastMethodSuccess() == false) {
System.out.println(mailman.lastErrorText());
return;
}
// ...
// ...
// ------------------------------------------------------------------------
// Do the equivalent using Email.SetFromXmlText.
CkStringBuilder sb = new CkStringBuilder();
success = sb.LoadFile(xmlFilePath,"utf-8");
if (success == false) {
System.out.println(sb.lastErrorText());
return;
}
CkEmail email = new CkEmail();
success = email.SetFromXmlText(sb.getAsString());
if (success == false) {
System.out.println(email.lastErrorText());
return;
}
}
}