public static void main(String[] args) throws Exception {
Message message = MessageBuilder.create()
.setFrom("John Doe <jdoe@machine.example>")
.setTo("Mary Smith <mary@example.net>")
.setSubject("Saying Hello")
.setDate(new Date())
.generateMessageId(InetAddress.getLocalHost().getCanonicalHostName())
.setBody("This is a message just to say hello.\r\nSo, \"Hello\".", Charsets.ISO_8859_1)
.build();
try {
MessageWriter writer = new DefaultMessageWriter();
writer.writeMessage(message, System.out);
} finally {
message.dispose();
}
}
}