Save Email Message using Aspose.Email and Apache POI HSMF

Aspose.Email - Save Email Message

MailMessage.save method is available to save EMail messages in various formats.

Java


 MailMessage messageMSG 	= MailMessage.load(dataDir + "message.msg");

messageMSG.save(dataDir + "AsposeMessage.msg");

messageMSG.save(dataDir + "AsposeMessage.eml");

messageMSG.save(dataDir + "AsposeMessage.emlx");

messageMSG.save(dataDir + "AsposeMessage.mht");

Apache POI HSMF - Save Email Message

EMail body can be extracted to create new file.

Java


 String filename = "message.msg";

MAPIMessage msg = new MAPIMessage(filename);

PrintWriter txtOut = new PrintWriter("ApacheMessage.txt");

txtOut.println("Email Body: " + msg.getTextBody());

txtOut.close();

Download Running Code

Download Sample Code