Class MapiMessage

MapiMessage class

Represents an Outlook Message format document that can be parsed.

public sealed class MapiMessage : MapiMessageItemBase

Constructors

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

Properties

NameDescription
Attachments { get; }Gets the attachments in the message.
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.
ClientSubmitTime { get; set; }Gets or sets the date and time the message sender submitted a message.
virtual CodePage { get; }Gets the code page.
Companies { get; set; }Contains the names of the companies that are associated with an item.
ConversationTopic { get; }Gets the topic of the first message in a conversation thread.
DeliveryTime { get; set; }Gets or sets the date and time a message was delivered.
DisplayBcc { get; }Gets a list of the display names of any blind carbon copy (BCC) message recipients, separated by semicolons (;).
DisplayCc { get; }Gets a list of the display names of any carbon copy (CC) message recipients, separated by semicolons (;).
DisplayName { get; }Gets the display name for the message.
DisplayNamePrefix { get; }Gets a prefix of the display name.
DisplayTo { get; }Gets a list of the display names of the primary (To) message recipients, separated by semicolons (;).
Flags { get; }Gets the message flags.
Headers { get; set; }Gets the transport message headers
InternetMessageId { get; }Gets the message id of the message.
IsEncrypted { get; }Gets a value indicating whether the message is encrypted.
IsSigned { get; }Gets a value indicating whether the message is signed.
IsTemplate { get; }Determines whether the message is Outlook template (.oft).
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.
MessageFormat { get; }Gets the outlook message format.
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.
NormalizedSubject { get; }Gets normalized subject of the message.
virtual Properties { get; }Gets the collection of properties.
PropertyStream { get; }Gets the property stream.
ReadReceiptRequested { get; set; }Gets or sets a value indicating whether the read receipt is requested.
Recipients { get; set; }Gets the recipients of the message.
ReplyTo { get; set; }Gets or sets the reply to names.
SenderAddressType { get; }Gets the message sender’s e-mail address type.
SenderEmailAddress { get; set; }Gets or sets the message sender’s e-mail address.
SenderName { get; set; }Gets or sets the message sender’s display name.
SenderSmtpAddress { get; set; }Gets or sets the message sender’s e-mail address.
Sensitivity { get; set; }Gets the Sensitivity.
SentRepresentingAddressType { get; }Gets the address type for the messaging user represented by the sender.
SentRepresentingEmailAddress { get; set; }Gets or sets the e-mail address for the messaging user represented by the sender.
SentRepresentingName { get; set; }Gets or sets the display name for the messaging user represented by the sender.
SentRepresentingSmtpAddress { get; }Gets or sets the e-mail address for the messaging user represented by the sender.
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.
TransportMessageHeaders { get; }Gets the transport-specific message envelope information.

Methods

NameDescription
static FromMailMessage(MailMessage)Creates an instance of MapiMessage from the MailMessage.
static FromMailMessage(Stream)Creates an instance of MapiMessage from the EML format data stream.
static FromMailMessage(string)Creates an instance of MapiMessage from the MailMessage.
static FromMailMessage(MailMessage, MapiConversionOptions)Creates an instance of MapiMessage from the MailMessage.
static FromProperties(MapiPropertyCollection)Creates an instance of MapiMessage from a collection of Mapi properties.
static Load(Stream)Loads message from stream.
static Load(string)Loads message from file.
static Load(Stream, LoadOptions)Loads message from stream with additional options.
static Load(string, LoadOptions)Loads message from file with additional options.
static LoadFromTnef(Stream)Loads message from Transport Neutral Encapsulation Format (TNEF) data structure
static LoadFromTnef(string)Loads message from Transport Neutral Encapsulation Format (TNEF) data structure
AddCustomProperty(MapiProperty, string)Adds the custom property.
AddCustomProperty(MapiPropertyType, byte[], string)Adds the custom property.
CheckBounced()Checks whether this message can be treated as a bounce message.
CheckSignature()Checking signature exsisting MapiMessage.
Clone()Creates a new object that is a copy of the current instance.
Decrypt()Decrypts this message
Decrypt(X509Certificate2)Decrypts this message
virtual Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
GetCustomProperties()Gets collection of custom MapiProperties.
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.
IsStoreUnicodeOk()Determines if string properties are Unicode encoded or not.
RemoveProperty(long)Provides correctly removing property from all collections.
RemoveSignature()Remove signature.
Save(Stream)Saves to the specified stream as Msg.
Save(string)Saves to the specified file as Msg.
Save(Stream, SaveOptions)Saves message as a stream with additional options.
Save(string, SaveOptions)Saves message as a file with additional options.
SaveAsTnef(Stream)Save message in TNEF format.
SaveAsTnef(string)Save message in TNEF format.
virtual 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.
SetStringPropertyValue(long, string)Sets the string property value.
ToMailMessage(MailConversionOptions)Creates an instance of MailMessage from this MapiMessage.
ToMapiMessageItem()Convert MapiMessage to IMapiMessageItem object in dependence with MessageClass.
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.
static DestroyAttachments(string)Destroies the attachments in the specified Outlook Message files. DestroyAttachments will ignore the attachment parsing.
static IsMsgFormat(Stream)Determines whether the specified stream has a MSG format.
static IsMsgFormat(string)Determines whether the specified file has a MSG format.
static RemoveAttachments(string)Removes all of the attachments from the specified Outlook Message files.

Remarks

Instances of the MapiMessage class are used to represent Microsoft Outlook Message document files that are parsed by MapiMessageReader class. To access the sender, recipient, and contents of an e-mail message, use the associated properties of the MapiMessage class.

Examples

The following exmaple demonstrates how to read Outlook Message files.

[C#]

//Open Outlook Message files
MapiMessage msg = MapiMessage.Load(@"c:\outlookmessage.msg");

/read subject
onsole.WriteLine("Subject:" + msg.Subject);

/sender name
onsole.WriteLine("From:" + msg.SenderName);

/message body
onsole.WriteLine("Body:" + msg.Body);

/Attachments
oreach(MapiAttachment att in msg.Attachments)

   Console.WriteLine("Attachment Name:"+att.FileName);
   att.Save(att.FileName);
    

[Visual Basic]

'Open Outlook Message files 
Dim msg As MapiMessage = MapiMessage.Load("c:\outlookmessage.msg") 

'read subject 
Console.WriteLine("Subject:" + msg.Subject) 

'sender name 
Console.WriteLine("From:" + msg.SenderName) 

'message body 
Console.WriteLine("Body:" + msg.Body) 

'Attachments 
For Each att As MapiAttachment In msg.Attachments 
    Console.WriteLine("Attachment Name:" + att.FileName) 
    att.Save(att.FileName) 
Next

See Also