مميزات MAPI
مميزات MAPI
كل ملف MSG يخزن البيانات كخصائص MAPI - أزواج القيمة الرئيسية المحددة بواسطة الهوية الممتلكات ورمز النموذج. Aspose.Email FOSS for .NET يعطي الوصول المباشر إلى هذه الميزات من خلال MapiMessage, MapiPropertyCollection,و و هو CommonMessagePropertyId إينوم .
قراءة الممتلكات
مميزات الراحة
MapiMessage يظهر الخصائص الأكثر شيوعا مثل خصائصه C# المسمى:
using Aspose.Email.Foss.Msg;
using var message = MapiMessage.FromFile("sample.msg");
Console.WriteLine(message.Subject); // string?
Console.WriteLine(message.Body); // string?
Console.WriteLine(message.HtmlBody); // string?
Console.WriteLine(message.SenderName); // string?
Console.WriteLine(message.SenderEmailAddress); // string?
Console.WriteLine(message.InternetMessageId); // string?
Console.WriteLine(message.MessageDeliveryTime); // DateTime?
Console.WriteLine(message.MessageClass); // string?الوصول إلى الممتلكات الخام
بالنسبة للممتلكات غير المعرضة كحقول الراحة، استخدام GetPropertyValue:
// Read a string property by ID and type
var displayTo = message.GetPropertyValue(
(ushort)CommonMessagePropertyId.DisplayTo,
(ushort)PropertyTypeCode.PtypString,
decode: true);
Console.WriteLine($"Display To: {displayTo}");إيتراي جميع الممتلكات
// List all property keys (ID + type pairs)
foreach (var (propId, propType) in message.IterPropertyKeys())
Console.WriteLine($"Property: 0x{propId:X4} (type: 0x{propType:X4})");
// Iterate full property objects
foreach (var prop in message.IterProperties())
{
Console.WriteLine($"ID=0x{prop.PropertyId:X4} " +
$"Type=0x{prop.PropertyType:X4} " +
$"Tag=0x{prop.PropertyTag:X8} " +
$"Value={prop.Value}");
}كتابة الممتلكات
إعداد الخصائص على رسالة جديدة
var message = MapiMessage.Create("Test", "Body");
message.SetProperty(
(ushort)CommonMessagePropertyId.SenderName,
(ushort)PropertyTypeCode.PtypString,
"Alice");
message.SetProperty(
(ushort)CommonMessagePropertyId.SenderEmailAddress,
(ushort)PropertyTypeCode.PtypString,
"alice@example.com");
message.SetProperty(
(ushort)CommonMessagePropertyId.MessageDeliveryTime,
(ushort)PropertyTypeCode.PtypTime,
new DateTime(2026, 3, 15, 10, 30, 0, DateTimeKind.Utc));الوصول المباشر إلى جمع
MapiPropertyCollection يقدم Add, Set, Get,و ، و Remove:
// Access the property collection
var props = message.Properties;
// Add a property
props.Add(
(ushort)CommonMessagePropertyId.InternetCodepage,
(ushort)PropertyTypeCode.PtypInteger32,
65001, // UTF-8
flags: 0);
// Read it back
var codepage = props.Get(
(ushort)CommonMessagePropertyId.InternetCodepage,
(ushort)PropertyTypeCode.PtypInteger32);
Console.WriteLine($"Codepage: {codepage?.Value}");
// Remove a property
props.Remove(
(ushort)CommonMessagePropertyId.InternetCodepage,
(ushort)PropertyTypeCode.PtypInteger32);الهوية المملوكة مشتركة
وَالْمُتَّقِينَ CommonMessagePropertyId يوفر enum مستويات تسمى لـ MAPI المستخدمة في كثير من الأحيان الهوية الممتلكات :
| الممتلكات | وصف |
|---|---|
Subject | موضوع الرسالة |
Body | جسم النص المسطح |
BodyHtml | HTML الجسم |
SenderName | اسم العرض |
SenderEmailAddress | إرسال عنوان البريد الإلكتروني |
DisplayTo | للمستلمين عرض الحبل |
DisplayCc | Cc المستلمين عرض الحبل |
DisplayBcc | Bcc المستلمين عرض الحبل |
InternetMessageId | RFC 5322 إدخال الرسائل |
MessageDeliveryTime | توفير الوقت |
TransportMessageHeaders | RFC الخام 5322 |
AttachFilename | اسم المرفق القصير |
AttachLongFilename | طويل الارتباط Filename |
AttachMimeTag | نوع المرفق MIME |
AttachContentId | إدراج المحتوى-ID |
نوع العقارات الرمزية
وَالْمُتَّقِينَ PropertyTypeCode خرائط enum MAPI نوع الرموز:
| نوع | وصف |
|---|---|
PtypString | شريط واحد |
PtypString8 | إس تيري |
PtypInteger32 | 32-bit integer |
PtypInteger64 | 64-bit integer |
PtypBoolean | بوليان |
PtypTime | تاريخ ( DateTime ) |
PtypBinary | بوتين أريلي |
PtypGuid | GUID |
ملكية الممتلكات
كل واحد منهم MapiAttachment كما أن لديها نفسها Properties جمع :
foreach (var attachment in message.Attachments)
{
Console.WriteLine($"Attachment: {attachment.Filename}");
foreach (var prop in attachment.Properties.IterProperties())
Console.WriteLine($" 0x{prop.PropertyTag:X8} = {prop.Value}");
}انظر أيضا
- قراءة ملفات MSG تحميل وتفتيش ملفات MSG
- EML التحويل - تحويل بين النماذج
- حاويات CFB - مستوى منخفض الوصول إلى حاويات ثنائية