MAPI गुण
MAPI गुण
हर MSG फ़ाइल डेटा को MAPI प्रॉपर्टीज़ — टैग्ड कुंजी‑मूल्य जोड़े, जो एक प्रॉपर्टी ID और टाइप कोड द्वारा पहचाने जाते हैं — के रूप में संग्रहीत करती है। 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 key in message.IterPropertyKeys())
Console.WriteLine($"Property: 0x{key:X8}");
// 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);सामान्य प्रॉपर्टी IDs
CommonMessagePropertyId enum अक्सर उपयोग किए जाने वाले MAPI प्रॉपर्टी IDs के लिए नामित स्थिरांक प्रदान करता है:
| Property | Description |
|---|---|
Subject | संदेश विषय |
Body | सादा पाठ बॉडी |
BodyHtml | HTML बॉडी |
SenderName | प्रेषक प्रदर्शन नाम |
SenderEmailAddress | प्रेषक ईमेल पता |
DisplayTo | To प्राप्तकर्ताओं का प्रदर्शन स्ट्रिंग |
DisplayCc | Cc प्राप्तकर्ताओं का प्रदर्शन स्ट्रिंग |
DisplayBcc | Bcc प्राप्तकर्ताओं का प्रदर्शन स्ट्रिंग |
InternetMessageId | RFC 5322 संदेश-ID |
MessageDeliveryTime | वितरण टाइमस्टैम्प |
TransportMessageHeaders | कच्चे RFC 5322 हेडर |
AttachFilename | छोटा अटैचमेंट फ़ाइलनाम |
AttachLongFilename | लंबा अटैचमेंट फ़ाइलनाम |
AttachMimeTag | अटैचमेंट MIME प्रकार |
AttachContentId | अटैचमेंट कंटेंट-ID |
संपत्ति प्रकार कोड
PropertyTypeCode enum MAPI प्रकार कोड को मैप करता है:
| प्रकार | विवरण |
|---|---|
PtypString | Unicode स्ट्रिंग |
PtypString8 | ANSI स्ट्रिंग |
PtypInteger32 | 32-बिट पूर्णांक |
PtypInteger64 | 64-बिट पूर्णांक |
PtypBoolean | बूलियन |
PtypTime | DateTime (FILETIME) |
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 कंटेनर — लो-लेवल बाइनरी कंटेनर एक्सेस