# MapiPropertyBag

Typed access to an ordered, duplicate-preserving MAPI property collection.

Class 

`OfficeIMO.Email`

**Namespace**

`OfficeIMO.Email`

**Assembly**

`OfficeIMO.Email`

**Source revision**

`be6c300e4ab1` with working tree changes

**Source**

[MapiPropertyBag.cs:14](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L14)

**Modifiers**

sealed

Typed access to an ordered, duplicate-preserving MAPI property collection.

## Inheritance

- object
- MapiPropertyBag

## Remarks

Reads use the last property with a matching canonical identity. Raw properties remain untouched until [MapiPropertyBag.Set](/api/email/officeimo-email-mapipropertybag/) or [MapiPropertyBag.Remove](/api/email/officeimo-email-mapipropertybag/) is called.

## Usage

Explore 6 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

### Returned or exposed by 5

- Property [EmailAttachment.Mapi](/api/email/officeimo-email-emailattachment/#property-mapi)
- Property [EmailDocument.Mapi](/api/email/officeimo-email-emaildocument/#property-mapi)
- Property [EmailRecipient.Mapi](/api/email/officeimo-email-emailrecipient/#property-mapi)
- Property [EmailStoreFolder.Mapi](/api/email/officeimo-email-store-emailstorefolder/#property-mapi)
- Property [EmailStoreFolderInfo.Mapi](/api/email/officeimo-email-store-emailstorefolderinfo/#property-mapi)

### Accepted by parameters 1

- Method [MapiPropertyPatch.Apply](/api/email/officeimo-email-mapipropertypatch/#method-apply-officeimo-email-mapipropertybag) parameter `bag`

Filter members 

Show inherited

## Constructors

`public MapiPropertyBag(IList<MapiProperty> properties)` [#](#constructor-ctor-collections-generic-ilist-officeimo-email-mapiproperty)

[MapiPropertyBag.cs:14](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L14)

Creates a typed view over an existing property collection.

Parameters

**properties System.Collections.Generic.IList<OfficeIMO.Email.MapiProperty> required**

## Methods

`public bool Contains(MapiPropertyKey key)` [#](#method-contains-officeimo-email-mapipropertykey)

[MapiPropertyBag.cs:44](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L44)

Returns whether at least one raw property has the specified canonical identity.

Parameters

**key OfficeIMO.Email.MapiPropertyKey required**

Returns

`bool`

`public MapiProperty? Find(MapiPropertyKey key)` [#](#method-find-officeimo-email-mapipropertykey)

[MapiPropertyBag.cs:23](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L23)

Finds the winning property with the key's canonical identity and an accepted wire type.

Parameters

**key OfficeIMO.Email.MapiPropertyKey required**

Returns

`MapiProperty?`

`public IReadOnlyList<MapiProperty> FindAll(MapiPropertyKey key)` [#](#method-findall-officeimo-email-mapipropertykey)

[MapiPropertyBag.cs:33](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L33)

Returns every property with the specified canonical identity and an accepted wire type.

Parameters

**key OfficeIMO.Email.MapiPropertyKey required**

Returns

`IReadOnlyList<MapiProperty>`

`public IReadOnlyList<MapiProperty> FindAllRaw(MapiPropertyKey key)` [#](#method-findallraw-officeimo-email-mapipropertykey)

[MapiPropertyBag.cs:39](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L39)

Returns every raw property with the specified canonical identity, in source order.

Parameters

**key OfficeIMO.Email.MapiPropertyKey required**

Returns

`IReadOnlyList<MapiProperty>`

`public MapiProperty? FindRaw(MapiPropertyKey key)` [#](#method-findraw-officeimo-email-mapipropertykey)

[MapiPropertyBag.cs:28](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L28)

Finds the winning raw property by canonical identity without requiring an accepted wire type.

Parameters

**key OfficeIMO.Email.MapiPropertyKey required**

Returns

`MapiProperty?`

`public T? GetNullableValue<T>(MapiPropertyKey<T> key)` [#](#method-getnullablevalue-officeimo-email-mapipropertykey)

[MapiPropertyBag.cs:58](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L58)

Reads the winning value-type property, or null when it is absent or incompatible.

Type Parameters

**T**

Parameters

**key OfficeIMO.Email.MapiPropertyKey<T> required**

Returns

`T?`

`public T? GetValueOrDefault<T>(MapiPropertyKey<T> key)` [#](#method-getvalueordefault-officeimo-email-mapipropertykey)

[MapiPropertyBag.cs:53](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L53)

Reads the winning typed value, or the managed default when it is absent or incompatible.

Type Parameters

**T**

Parameters

**key OfficeIMO.Email.MapiPropertyKey<T> required**

Returns

`T?`

`public int Remove(MapiPropertyKey key)` [#](#method-remove-officeimo-email-mapipropertykey)

[MapiPropertyBag.cs:127](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L127)

Removes all properties with the specified canonical identity.

Parameters

**key OfficeIMO.Email.MapiPropertyKey required**

Returns

`int` The number of removed raw properties.

`public MapiProperty SetNull(MapiPropertyKey key, MapiPropertyType wireType, uint? flags = null)` [#](#method-setnull-officeimo-email-mapipropertykey-officeimo-email-mapipropertytype-nullable-system-uint32)

[MapiPropertyBag.cs:81](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L81)

Writes a null placeholder for an object or null-typed MAPI property.

Parameters

**key OfficeIMO.Email.MapiPropertyKey required**

**wireType OfficeIMO.Email.MapiPropertyType required**

**flags uint? = null optional**

Returns

`MapiProperty`

Set``1 2 overloads

`public MapiProperty Set<T>(MapiPropertyKey<T?> key, T? value, uint? flags = null)` [#](#method-set-officeimo-email-mapipropertykey-nullable-system-uint32)

[MapiPropertyBag.cs:66](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L66)

Replaces every property with the same canonical identity and appends one property using the key's preferred wire type. Existing mapped property ID and flags are retained unless flags are supplied explicitly.

Type Parameters

**T**

Parameters

**key OfficeIMO.Email.MapiPropertyKey<T?> required**

**value T? required**

**flags uint? = null optional**

Returns

`MapiProperty`

`public MapiProperty Set<T>(MapiPropertyKey<T?> key, T? value, MapiPropertyType wireType, uint? flags = null)` [#](#method-set-officeimo-email-mapipropertykey-officeimo-email-mapipropertytype-nullable-system-uint32)

[MapiPropertyBag.cs:74](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L74)

Writes a value using one of the key's accepted wire types.

Type Parameters

**T**

Parameters

**key OfficeIMO.Email.MapiPropertyKey<T?> required**

**value T? required**

**wireType OfficeIMO.Email.MapiPropertyType required**

**flags uint? = null optional**

Returns

`MapiProperty`

`public bool TryGetValue<T>(MapiPropertyKey<T> key, out T? value)` [#](#method-trygetvalue-officeimo-email-mapipropertykey)

[MapiPropertyBag.cs:48](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L48)

Attempts to read the winning property using the key's wire and managed type contract.

Type Parameters

**T**

Parameters

**key OfficeIMO.Email.MapiPropertyKey<T> required**

**value T? required**

Returns

`bool`

## Inherited Methods

`public virtual bool Equals(object? obj)` [#](#method-equals-object)

Inherited from object

Parameters

**obj object? required**

Returns

`bool`

`public virtual int GetHashCode()` [#](#method-gethashcode)

Inherited from object

Returns

`int`

`public Type GetType()` [#](#method-gettype)

Inherited from object

Returns

`Type`

`public virtual string? ToString()` [#](#method-tostring)

Inherited from object

Returns

`string?`

## Properties

`public IList<MapiProperty> Properties { get; }` [#](#property-properties)

[MapiPropertyBag.cs:19](https://github.com/EvotecIT/OfficeIMO/blob/be6c300e4ab1859837b961c64fbfb2b2a1886cd0/Sources/OfficeIMO.Email/Mapi/MapiPropertyBag.cs#L19)

The exact mutable raw collection backing this bag.

<!-- PowerForge markdown artifact sha256:2992A572B9FD3B5C2AEB78C77A044E21CE3E3F271AE4E0C625CA2DC068E86217 -->
