CkJava Requires Chilkat v11.0.0+
CkJava
Create a message disposition notification
See more Email Object Examples
An MDN describes a recipient-side event such as displaying a message. Create one only when the application has an appropriate request and the recipient has consented. Set Final-Recipient from the actual receiving mailbox. MDN format.
Chilkat CkJava 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;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
CkEmail email = new CkEmail();
success = email.LoadEml("message.eml");
if (success != true) {
System.out.println(email.lastErrorText());
return;
}
CkXml fields = new CkXml();
fields.put_Tag("DispositionFields");
fields.NewChild2("Final-Recipient","rfc822; alex@example.net");
String originalId = email.getHeaderField("Message-ID");
if (originalId != "") {
fields.NewChild2("Original-Message-ID",originalId);
}
fields.NewChild2("Disposition","manual-action/MDN-sent-manually; displayed");
CkEmail report = new CkEmail();
success = email.ToMdn("The recipient displayed your message.",fields.getXml(),true,report);
if (success != true) {
System.out.println(email.lastErrorText());
return;
}
report.put_From("Alex Rivera <alex@example.net>");
success = report.SaveEml("disposition.eml");
if (success != true) {
System.out.println(report.lastErrorText());
return;
}
System.out.println("Saved disposition.eml.");
}
}