Working with MAPI Properties

Accessing and Setting Outlook MAPI Property

The MapiProperty class represents a MAPI property, which contains:

  • Name: a string that represents the property’s name.
  • Tag: a long that represents the property’s tag.
  • Data: a byte array which represents the property’s data.

Getting MAPI Property using the MAPI Property Tag

To get MAPI properties:

  1. Create an instance of MapiMessage by loading from files or stream.
  2. Get the MapiProperty from MapiMessage.Properties by MapiPropertyTag keys.

The following code snippet shows you how to get MAPI property using the MAPI property tag.

Setting MAPI Properties

The following code snippet shows you how to set MAPI properties.

where the definition of convertDateTime method is as follow:

Some Additional Properties

The following code snippet shows you how to set additional MAPI properties.

Reading Named MAPI Properties from Outlook MSG Files

Microsoft Outlook supports adding named MAPI properties to an MSG file. These named MAPI properties are added by the user. You can add a named property, for example, “MyProp”, to an MSG file using Aspose.Email. This article illustrates Aspose.Email’s capabilities to:

Read Named MAPI Properties from MSG file

The following code snippet shows you how to read named MAPI properties from the MSG file.

Reading Named MAPI Property from Attachment

Aspose.Email also allows you to traverse through the properties of a MapiAttachment and search for a named property, in a way similar to the example above, for MapiMessage. The following code snippet shows you how to search for a named property through the attachment’s property collection.

Remove Properties from MSGs and Attachments

The following code snippet shows you how to remove properties from MSGs and attachments.