Class MapiContact

MapiContact class

Represents a MAPI contact item.

public sealed class MapiContact : MapiMessageItemBase

Constructors

NameDescription
MapiContact()Initializes a new instance of the MapiContact class
MapiContact(string, string)Initializes a new instance of the MapiContact class.
MapiContact(string, string, string)Initializes a new instance of the MapiContact class.
MapiContact(string, string, string, string)Initializes a new instance of the MapiContact class.

Properties

NameDescription
Attachments { get; }Gets the attachments in the contact.
Billing { get; set; }Contains the billing information associated with an item.
Body { get; set; }Gets the message text.
BodyHtml { get; }Gets the BodyRtf of the message converted to HTML, if present, otherwise an empty string.
BodyRtf { get; set; }Gets or sets the RTF formatted message text.
BodyType { get; }Gets the type of the body.
Categories { get; set; }Contains keywords or categories for the message object.
virtual CodePage { get; }Gets the code page.
Companies { get; set; }Contains the names of the companies that are associated with an item.
ElectronicAddresses { get; set; }Specify properties for up to three different e-mail addresses and three different fax addresses
Events { get; set; }Specify events associated with a contact
virtual ItemId { get; }The item id, uses with a server
MessageClass { get; set; }Gets a case-sensitive string that identifies the sender-defined message class, such as IPM.Note. The message class specifies the type, purpose, or content of the message.
Mileage { get; set; }Contains the mileage information that is associated with an item.
NamedProperties { get; }Gets the named properties of message.
NamedPropertyMapping { get; }Gets the named property mapping.
NameInfo { get; set; }The properties are used to specify the name of the person represented by the contact
OtherFields { get; set; }Specify other fields of conhtact.
PersonalInfo { get; set; }Specify other additional contact information
Photo { get; set; }Contains contact photoMapiContactPhoto.
PhysicalAddresses { get; set; }Specify three physical addresses: Home Address, Work Address, and Other Address. One of the addresses can be marked as the Mailing Address
ProfessionalInfo { get; set; }Properties are used to store professional details for the person represented by the contact
virtual Properties { get; }Gets the collection of properties.
PropertyStream { get; }Gets the property stream.
Recipients { get; set; }Gets the recipients of the message.
Sensitivity { get; set; }Gets the Sensitivity.
Subject { get; set; }Gets or sets the subject of the message.
SubjectPrefix { get; }Gets a subject prefix that typically indicates some action on a message, such as “FW: " for forwarding.
SubStorages { get; }Gets the sub storages.
SupportedType { get; }Gets the supported item type.
Telephones { get; set; }Specify telephone numbers for the contact

Methods

NameDescription
static FromVCard(Stream)Reads MapiContact from the specified stream containing vCard. The supported vCard versions are 2.1 and 3.0
static FromVCard(string)Reads MapiContact from the specified vCard file The supported vCard versions are 2.1 and 3.0
static FromVCard(Stream, Encoding)Reads MapiContact from the specified stream containing vCard. The supported vCard versions are 2.1 and 3.0
static FromVCard(string, Encoding)Reads MapiContact from the specified vCard file The supported vCard versions are 2.1 and 3.0
virtual Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
override GetProperty(PropertyDescriptor)Gets MAPI property by property descriptor.
GetPropertyBoolean(long)Gets the value of the property specified by tag as Boolean type.
GetPropertyBytes(long)Gets the string value of the property specified by tag.
GetPropertyDateTime(long)Gets the value of the property specified by tag as DateTime type.
GetPropertyInt32(long)Gets the int32 value of the property specified by tag.
GetPropertyLong(long)Gets the value of the property specified by tag as Long (int64) type.
GetPropertyShort(long)Gets the value of the property specified by tag as Short type.
GetPropertyString(long)Gets the string value of the property specified by tag.
GetPropertyString(long, int)Gets the string value of the property specified by tag.
GetUnderlyingMessage()Retrieves the underlying MapiMessage object.
IsStoreUnicodeOk()Determines if string properties are Unicode encoded or not.
RemoveProperty(long)Provides correctly removing property from all collections.
Save(Stream)Saves this MapiContact into the given stream with vCard format. The supported vCard version is 2.1
Save(string)Saves this MapiContact to the vCard file with a default options. The supported vCard version is 2.1
Save(Stream, ContactSaveFormat)Saves this MapiContact to the given stream with a format using the default options. The supported save format is vCard
Save(Stream, ContactSaveOptions)Saves this MapiContact to the given stream using specified save options. The supported save options is VCardSaveOptions
Save(string, ContactSaveFormat)Saves this MapiContact to the specified file with a format using the default options. The supported save format is vCard.
Save(string, ContactSaveOptions)Saves this MapiContact into file using specified save options. The supported save options is VCardSaveOptions
override SetBodyContent(string, BodyContentType)Sets the content of the body.
virtual SetBodyContent(string, BodyContentType, bool)Sets the content of the body.
SetBodyRtf(string, bool)Gets or sets the RTF formatted message text.
SetMessageFlags(MapiMessageFlags)Sets the message flags.
virtual SetProperty(MapiProperty)Sets the property.
override SetProperty(PropertyDescriptor, object)Sets MAPI property.
TryGetPropertyData(long)Try to get the property data with specified tag key.
TryGetPropertyDateTime(long, ref DateTime)Gets the value of the specified property as DateTime type. A return value indicates whether the operation succeeded.
TryGetPropertyInt32(long, ref int)Gets the value of the specified property as Int32 type. A return value indicates whether the operation succeeded.
TryGetPropertyLong(long, ref long)Gets the value of the specified property as Long type. A return value indicates whether the operation succeeded.
TryGetPropertyString(long)Try to get a property data as string with specified tag.
TryGetPropertyString(long, int)Try to get a property data as string with specified tag and code page.
TryGetPropertyString(long, ref string)Gets the value of the specified property as String type. A return value indicates whether the operation succeeded.
TryGetPropertyString(long, ref string, int)Gets the value of the specified property as String type. A return value indicates whether the operation succeeded.

Remarks

This class serves as a wrapper for MapiMessage to simplify the process of handling contact information from MAPI properties. It provides a more intuitive interface for accessing and manipulating contact data within the MAPI message.

Examples

The following exmaple demonstrates how to get MapiContact object from MapiMessage.

[C#]

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

// Check if the loaded message is a supported contact type
if (msg.SupportedType == MapiItemType.Contact)
{
    // Convert the MAPI message to a MapiContact object
    var mapiContact = (MapiContact)msg.ToMapiMessageItem();
    
    // Display some contact info
    Console.WriteLine(mapiContact.NameInfo.DisplayName);
    Console.WriteLine(mapiContact.ElectronicAddresses.Email1.EmailAddress);
}

[Visual Basic]

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

' Check if the loaded message is a supported contact type
If msg.SupportedType = MapiItemType.Contact Then
    ' Convert the MAPI message to a MapiContact object
    Dim mapiContact = DirectCast(msg.ToMapiMessageItem(), MapiContact)
    
    ' Display some contact info
    Console.WriteLine(mapiContact.NameInfo.DisplayName)
    Console.WriteLine(mapiContact.ElectronicAddresses.Email1.EmailAddress)
End If

See Also