مميزات 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جسم النص المسطح
BodyHtmlHTML الجسم
SenderNameاسم العرض
SenderEmailAddressإرسال عنوان البريد الإلكتروني
DisplayToللمستلمين عرض الحبل
DisplayCcCc المستلمين عرض الحبل
DisplayBccBcc المستلمين عرض الحبل
InternetMessageIdRFC 5322 إدخال الرسائل
MessageDeliveryTimeتوفير الوقت
TransportMessageHeadersRFC الخام 5322
AttachFilenameاسم المرفق القصير
AttachLongFilenameطويل الارتباط Filename
AttachMimeTagنوع المرفق MIME
AttachContentIdإدراج المحتوى-ID

نوع العقارات الرمزية

وَالْمُتَّقِينَ PropertyTypeCode خرائط enum MAPI نوع الرموز:

نوعوصف
PtypStringشريط واحد
PtypString8إس تيري
PtypInteger3232-bit integer
PtypInteger6464-bit integer
PtypBooleanبوليان
PtypTimeتاريخ ( DateTime )
PtypBinaryبوتين أريلي
PtypGuidGUID

ملكية الممتلكات

كل واحد منهم 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}");
}

انظر أيضا

 العربية