Class MapiPropertyContainer

MapiPropertyContainer class

The base class of the objects that consist of MAPI properties: messages, attachments and recipients.

public class MapiPropertyContainer

Properties

NameDescription
virtual CodePage { get; }Gets the code page of the ANSI strings of the object.
virtual Properties { get; }Gets all properties of the object.

Methods

NameDescription
virtual GetProperty(PropertyDescriptor)Gets a MAPI property by its descriptor.
GetPropertyBoolean(long)Gets the value of a property as a Boolean.
GetPropertyBytes(long)Gets the value of a property as bytes.
GetPropertyDateTime(long)Gets the value of a property as a date and time.
GetPropertyInt32(long)Gets the value of a property as a 32-bit integer.
GetPropertyLong(long)Gets the value of a property as a 64-bit integer.
GetPropertyShort(long)Gets the value of a property as a 16-bit integer.
GetPropertyString(long)Gets the value of a property as a string.
GetPropertyString(long, int)Gets the value of a property as a string, decoding an ANSI string with the specified code page.
IsStoreUnicodeOk()Determines whether the string properties of the object are stored in Unicode.
virtual SetProperty(MapiProperty)Adds the property, or replaces the property with the same tag.
virtual SetProperty(PropertyDescriptor, object)Sets the value of a MAPI property, creating the property if needed.
TryGetPropertyData(long)Gets the value of a property as bytes.
TryGetPropertyDateTime(long, ref DateTime)Gets the value of a property as a date and time, if the property exists.
TryGetPropertyInt32(long, ref int)Gets the value of a property as a 32-bit integer, if the property exists.
TryGetPropertyLong(long, ref long)Gets the value of a property as a 64-bit integer, if the property exists.
TryGetPropertyString(long)Gets the value of a property as a string.
TryGetPropertyString(long, int)Gets the value of a property as a string, decoding an ANSI string with the specified code page.
TryGetPropertyString(long, ref string)Gets the value of a property as a string, if the property exists.
TryGetPropertyString(long, ref string, int)Gets the value of a property as a string, if the property exists, decoding an ANSI string with the specified code page.

Remarks

Properties are read and written either by tag, with the constants of MapiPropertyTag, or by descriptor, with the descriptors of KnownPropertyList. Descriptors also cover named properties, which have no fixed tag.

Examples

This example reads properties by tag and by descriptor, and adds a custom named property.

[C#]

var msg = MapiMessage.Load("message.msg");

// by tag
string subject = msg.GetPropertyString(MapiPropertyTag.PR_SUBJECT);
DateTime? delivered = msg.GetPropertyDateTime(MapiPropertyTag.PR_MESSAGE_DELIVERY_TIME);

// by descriptor; works for named properties too
MapiProperty importance = msg.GetProperty(KnownPropertyList.Importance);

// a custom named property in the PS_PUBLIC_STRINGS property set
var projectCode = new PidNamePropertyDescriptor("ProjectCode", PropertyDataType.String,
    KnownPropertySets.PublicStrings);
msg.SetProperty(projectCode, "PRJ-42");
msg.Save("message-with-code.msg");

[Visual Basic]

Dim msg = MapiMessage.Load("message.msg")

' by tag
Dim subject As String = msg.GetPropertyString(MapiPropertyTag.PR_SUBJECT)
Dim delivered As DateTime? = msg.GetPropertyDateTime(MapiPropertyTag.PR_MESSAGE_DELIVERY_TIME)

' by descriptor; works for named properties too
Dim importance As MapiProperty = msg.GetProperty(KnownPropertyList.Importance)

' a custom named property in the PS_PUBLIC_STRINGS property set
Dim projectCode = New PidNamePropertyDescriptor("ProjectCode", PropertyDataType.String,
    KnownPropertySets.PublicStrings)
msg.SetProperty(projectCode, "PRJ-42")
msg.Save("message-with-code.msg")

See Also