Element message = new Element("message",
new Element[] {new Element("body", body)},
new String[] {"to", "from", "type"},
new String[] {to, from, type.toString()});
if (subject != null) {
message.addChild(new Element("subject", subject));
}
if (thread != null) {
message.addChild(new Element("thread", thread));
}
return new Packet(message);