MapiMessage Class
An item of an Outlook data file: an email, or the base of the typed items (contacts, appointments, tasks, distribution lists, notes, journal entries).
public class MapiMessageExample
using var file = PstFile.Open(path);
var message = file.GetFolder("Inbox")!.EnumerateItems().First();
Assert.Equal("Welcome to Microsoft Office Outlook 2003", message.Subject);
Assert.Equal("Outlook 2003 Team", message.SenderName);
Assert.Single(message.Recipients);
Assert.HasCount(11, message.Attachments);
Assert.Contains("Outlook", message.Body, StringComparison.Ordinal);Properties
| Name | Description |
|---|---|
| Attachments | Gets the attachments of the item. |
| Body | Gets the plain text body. |
| BodyHtml | Gets the HTML body, decoded with the code page of the message. |
| Categories | Gets the categories of the item. |
| ClientSubmitTime | Gets the date and time, in UTC, when the message was sent. |
| ConversationTopic | Gets the subject without its prefix, the topic of the conversation. |
| CreationTime | Gets the date and time, in UTC, when the item was created. |
| DisplayBcc | Gets the display names of the Bcc recipients, separated by semicolons. |
| DisplayCc | Gets the display names of the Cc recipients, separated by semicolons. |
| DisplayTo | Gets the display names of the To recipients, separated by semicolons. |
| Flags | Gets the flags of the message, such as read or unsent. |
| HasAttachments | Gets whether the item has attachments, according to the attachment table. |
| HasRtfBody | Gets whether the message has a compressed RTF body. |
| Importance | Gets the importance of the item. |
| InReplyToId | Gets the In-Reply-To header of the message. |
| InternetMessageId | Gets the Message-ID header of the message. |
| InternetReferences | Gets the References header of the message. |
| IsAssociated | Gets whether the item is an associated (hidden) item of its folder. |
| IsEmbedded | Gets whether the item is an embedded message, the content of an attachment. |
| IsRead | Gets whether the message has been read. |
| LastModificationTime | Gets the date and time, in UTC, when the item was last modified. |
| MessageClass | Gets the class of the item, such as IPM.Note, IPM.Contact or IPM.Appointment. |
| MessageDeliveryTime | Gets the date and time, in UTC, when the message was received. |
| NodeId | Gets the identifier of the node of the item in the Outlook data file. For an embedded message, it is the identifier of a subnode of its attachment. It is 0 for an item that is not in an Outlook data file, such as the message of an .msg file. |
| Properties | Gets the properties of the item. |
| Recipients | Gets the recipients of the message. |
| ReplyRecipients | Gets the recipients that replies go to (the Reply-To header of an email), from their one-off entry identifiers; the other entry identifiers are skipped. |
| SenderAddressType | Gets the type of the address of the sender, such as SMTP or EX. |
| SenderEmailAddress | Gets the address of the sender, in the format of MapiMessage.SenderAddressType. |
| SenderName | Gets the display name of the sender. |
| SenderSmtpAddress | Gets the SMTP address of the sender, or the address of the sender when its type is SMTP. |
| Sensitivity | Gets the sensitivity of the item. |
| SentRepresentingAddressType | Gets the type of the address of the user the message was sent on behalf of, such as SMTP or EX. |
| SentRepresentingEmailAddress | Gets the address of the user the message was sent on behalf of. |
| SentRepresentingName | Gets the display name of the user the message was sent on behalf of. |
| SentRepresentingSmtpAddress | Gets the SMTP address of the user the message was sent on behalf of, or their address when its type is SMTP. |
| Size | Gets the size of the message, as stored in the file. |
| Subject | Gets the subject, without the control characters Outlook stores before the prefix (such as RE: ). |
| TransportMessageHeaders | Gets the headers of the message as received by the transport. |
Attachments
MapiMessage.csGets the attachments of the item.
public IReadOnlyList<MapiAttachment> Attachments { get; }Body
MapiMessage.csBodyHtml
MapiMessage.csCategories
MapiMessage.csClientSubmitTime
MapiMessage.csConversationTopic
MapiMessage.csCreationTime
MapiMessage.csDisplayBcc
MapiMessage.csDisplayCc
MapiMessage.csDisplayTo
MapiMessage.csFlags
MapiMessage.csGets the flags of the message, such as read or unsent.
public MapiMessageFlags Flags { get; }Property value
HasAttachments
MapiMessage.csHasRtfBody
MapiMessage.csImportance
MapiMessage.csInReplyToId
MapiMessage.csInternetMessageId
MapiMessage.csInternetReferences
MapiMessage.csIsAssociated
MapiMessage.csIsEmbedded
MapiMessage.csIsRead
MapiMessage.csLastModificationTime
MapiMessage.csMessageClass
MapiMessage.csMessageDeliveryTime
MapiMessage.csNodeId
MapiMessage.csProperties
MapiMessage.csRecipients
MapiMessage.csGets the recipients of the message.
public IReadOnlyList<MapiRecipient> Recipients { get; }ReplyRecipients
MapiMessage.csGets the recipients that replies go to (the Reply-To header of an email), from their one-off entry identifiers; the other entry identifiers are skipped.
public IReadOnlyList<MapiDistributionListMember> ReplyRecipients { get; }Property value
SenderAddressType
MapiMessage.csSenderEmailAddress
MapiMessage.csGets the address of the sender, in the format of MapiMessage.SenderAddressType.
public string? SenderEmailAddress { get; }Property value
SenderName
MapiMessage.csSenderSmtpAddress
MapiMessage.csSensitivity
MapiMessage.csSentRepresentingAddressType
MapiMessage.csSentRepresentingEmailAddress
MapiMessage.csSentRepresentingName
MapiMessage.csSentRepresentingSmtpAddress
MapiMessage.csSize
MapiMessage.csSubject
MapiMessage.csTransportMessageHeaders
MapiMessage.csMethods
| Name | Description |
|---|---|
| GetHtmlBody() | Returns the HTML body: the HTML property, or the HTML encapsulated in the RTF body when the message has no HTML property, as Outlook often stores it ([MS-OXRTFEX]). |
| GetRtfBody() | Returns the RTF body, decompressed from the compressed RTF property. |
| GetTextBody() | Returns the plain text body: the body property, or the text encapsulated in the RTF body when the message has no body property ([MS-OXRTFEX]). |
| ToString() | Returns the subject. |
GetHtmlBody()
MapiMessage.csReturns the HTML body: the HTML property, or the HTML encapsulated in the RTF body when the message has no HTML property, as Outlook often stores it ([MS-OXRTFEX]).
public string? GetHtmlBody()Returns
string? The HTML, or null when the message has no HTML body.
Exceptions
InvalidEmailDataException- The compressed RTF is malformed.
GetRtfBody()
MapiMessage.csReturns the RTF body, decompressed from the compressed RTF property.
public byte[]? GetRtfBody()Returns
byte[]? The RTF, or null when the message has no RTF body.
Exceptions
InvalidEmailDataException- The compressed RTF is malformed.
GetTextBody()
MapiMessage.csReturns the plain text body: the body property, or the text encapsulated in the RTF body when the message has no body property ([MS-OXRTFEX]).
public string? GetTextBody()Returns
string? The text, or null when the message has no plain text body.
Exceptions
InvalidEmailDataException- The compressed RTF is malformed.