Extract Message Headers using Aspose.Email and Apache POI HSMF

Aspose.Email - Extract Message Headers

The email header represents an Internet and RFC defined standard set of header fields included in Internet email messages. An email header can be specified using the MailMessage class. Common header types are defined in the HeaderType class. It is a sealed class working like normal enumeration.


 //Gets Email Headers

System.out.println("From: " 	+ message.getFrom());

System.out.println("To: " 	+ message.getTo());

System.out.println("CC: " 	+ message.getCC());

System.out.println("Bcc: " 	+ message.getBcc());

System.out.println("Subject: " 	+ message.getSubject());

Apache POI HSMF - Extract Message Headers

MAPIMessage class provides the methods to access headers of email messages.


 MAPIMessage msg = new MAPIMessage(dataDir + "message.msg");

System.out.println("From: " + msg.getDisplayFrom());

System.out.println("To: " + msg.getDisplayTo());

System.out.println("CC: " + msg.getDisplayCC());

System.out.println("BCC: " + msg.getDisplayBCC());

System.out.println("Subject: " + msg.getSubject());

Download Running Code

Download Sample Code