Parsing Outlook Message Files

Contents
[ ]

Aspose.Email for Java provides the MapiMessage class that is used to open and parse an MSG file. As there may be many recipients in an MSG file, the MapiMessage class exposes the getRecipients() method that returns a MapiRecipientCollection which represents a collection of MapiRecipient objects. The MapiRecipient object further exposes methods for working with recipient attributes.

The following sequence of steps serves this purpose:

  1. Create an instance of the MapiMessage class to load an MSG file from the fromFile static method.
  2. Display the sender name, subject, and body from the MSG file using getSenderName(), getSubject() and getBody() methods.
  3. Call the getRecipients() method exposed by the MapiRecipient class to get a reference to the collection of MapiRecipient objects associated with the MSG file.
  4. Loop through the MapiRecipientCollection collection to display contents for each MapiRecipient object through its public methods.