Working with MAPI Properties

Setting and Accessing Outlook MAPI Properties

Aspose.Email for Java provides the MapiProperty class that represents a MAPI property:

  • Name: the property name.
  • Tag: the property’s tag.
  • Data: the property data.

This topic also discusses how to set and access an Outlook Message (MSG) file’s MAPI properties using Aspose.Email for Java. In addition, a sample code has been provided about how to remove properties from MSGs and Attachments.

Read Properties

To read data of MAPI properties from an MSG file:

  1. Create an instance of the MapiMessage class to load an MSG file using the fromFile() static method.
  2. Set a reference to the MapiMessage object’s getProperties() method to get the MapiPropertyCollection.
  3. Get the MapiProperty object from the MapiPropertyCollection by the MapiPropertyTag keys.
  4. Get the property data using an appropriate getXXX() method.  

Set Additional Properties

The following code sample can be used to set additional properties of an Outlook MapiMessage.

Remove Properties

Reading Named Mapi Properties from Email Messages

Microsoft Outlook supports adding named MAPI properties to an MSG file. These properties are added by the user. Developers can add a named property, for example “MyProp”, to an MSG file using Aspose.Email.

This article illustrates Aspose.Email’s MapiMessage getNamedProperties() collection to read named MAPI properties from an MSG file.

Read Named MAPI Property

Read Named Mapi Property from Attachment