MapiMessage

概述

MapiMessage 是 Aspose.Email FOSS 库中用于读取和写入 .msg 邮件文件的主要类。使用 FromFile、FromStream 或 LoadFromEml 的重载之一加载现有邮件。使用 Create 构建新邮件,然后调用 AddRecipient 和 AddAttachment。使用 Save 将其保存回 .msg,或使用 SaveToEml 导出为 EML。实现 IDisposable;使用 using 块以确保资源被释放。

方法

签名描述
Create(subject: string, body: string, unicodeStrings: bool)创建一个新的 MapiMessage,使用给定的主题和正文,可选地使用 Unicode 字符串。
FromFile(path: string, strict: bool)从位于 path 的 .msg 文件加载 MapiMessage;strict 启用完整的结构验证。
FromStream(stream: Stream, strict: bool)从 stream 加载 MapiMessage;strict 启用完整的结构验证。
FromMsgDocument(document: MsgDocument)将已解析的 MsgDocument 包装在 MapiMessage 中。
LoadFromEml(path: string)通过内存 MIME 解析,将位于 path 的 EML 文件转换为 MapiMessage。
LoadFromEml(stream: Stream)通过内存 MIME 解析,将位于 path 的 EML 文件转换为 MapiMessage。
LoadFromEml(data: byte[])通过内存 MIME 解析,将位于 path 的 EML 文件转换为 MapiMessage。
Dispose()释放此消息持有的非托管资源。
AddRecipient(emailAddress: string, displayName: string?, recipientType: int)添加一个收件人,使用给定的电子邮件地址、显示名称和类型(1 = To,2 = Cc,3 = Bcc)。
AddAttachment(filename: string, data: byte[], mimeType: string?, contentId: string?)通过文件名和二进制数据附加文件,可选地指定 MIME 类型和 Content-ID。
AddAttachment(filename: string, stream: Stream, mimeType: string?, contentId: string?)通过文件名和二进制数据附加文件,可选地指定 MIME 类型和 Content-ID。
AddEmbeddedMessageAttachment(message: MapiMessage, filename: string?, mimeType: string?)将另一个 MapiMessage 作为嵌入式消息附件附加。
SetProperty(propertyId: ushort, propertyType: ushort, value: object?, flags: uint)通过属性 ID、类型、值和标志设置原始 MAPI 属性。
GetPropertyValue(propertyId: ushort, propertyType: ushort?, decode: bool)按 ID(以及可选类型)检索 MAPI 属性的值;decode 控制字符串解码。
IterPropertyKeys()枚举所有已存储属性的 (propertyId, propertyType) 键对。
IterProperties()枚举此消息中存储的所有 MapiProperty 对象。
IterAttachmentsInfo()枚举附件元数据,而不加载完整的附件数据。
ToMsgDocument()将此 MapiMessage 转换为适用于 CFB 序列化的 MsgDocument。
Save()就地保存消息(针对最初从文件或流加载的消息)。
Save(path: string)就地保存消息(针对最初从文件或流加载的消息)。
Save(stream: Stream)将消息就地保存(适用于最初从文件或流加载的消息)。
SaveToEml()将消息就地保存(适用于最初从文件或流加载的消息)。
SaveToEml(path: string)将消息就地保存(适用于最初从文件或流加载的消息)。
SaveToEml(stream: Stream)将消息就地保存(适用于最初从文件或流加载的消息)。

属性

名称类型访问描述
RecipientTypeToint读取常量值 1 用于收件人(To)
RecipientTypeCcint读取常量值 2 用于收件人(Cc)
RecipientTypeBccint读取常量值 3 用于收件人(Bcc)
UnicodeStringsbool读取如果字符串属性以 Unicode 方式存储则为 true(PT_UNICODE);如果是 ANSI 则为 false(PT_STRING8)。
PropertiesMapiPropertyCollection读取此消息的顶层 MAPI 属性集合。
RecipientsIList<MapiRecipient>读取按顺序排列的 MapiRecipient 条目列表,针对 To、Cc 和 Bcc 地址。
AttachmentsIList<MapiAttachment>读取有序的 MapiAttachment 条目列表。
MajorVersionushort读取来自底层复合文件头的 CFB 主版本号。
MinorVersionushort读取来自底层复合文件头的 CFB 次要版本。
TransactionSignatureNumberuint读取来自文件头的 CFB 事务签名编号。
ValidationIssuesIReadOnlyList<string>读取在启用 strict 模式时检测到的结构验证问题列表。
Subjectstring?读取消息主题字符串,如果未设置则为 null。
Bodystring?读取纯文本消息正文,如果未设置则为 null。
HtmlBodystring?读取HTML 格式的消息正文,如果未设置则为 null。
MessageClassstring?读取MAPI 消息类字符串(例如 IPM.Note),如果未设置则为 null。
SenderNamestring?读取发件人显示名称,如果未设置则为 null。
SenderEmailAddressstring?读取发件人 SMTP 电子邮件地址,如果未设置,则为 null。
SenderAddressTypestring?读取发送者地址类型字符串(例如 SMTP),如果未设置则为 null。
InternetMessageIdstring?读取RFC 2822 Message-ID 值,如果未设置则为 null。
MessageDeliveryTimeDateTime?读取交付时间戳为 DateTime?,如果未设置则为 null。

另请参阅

 中文