MAPI ΙΔΙΟΤΗΤΑ
MAPI ΙΔΙΟΤΗΤΑ
Κάθε αρχείο MSG αποθηκεύει δεδομένα ως ιδιότητες MAPI — τα ζεύγη κλειδιά-αξίας που αναγνωρίζονται από ένα Ιδιοκτήτης ιδιοκτησίας και κωδικός τύπου.Email FOSS για .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);Κοινή Ιδιοκτησία IDs
Η CommonMessagePropertyId Το enum παρέχει ονομαστικές σταθερές για συχνά χρησιμοποιούμενες MAPIs. Ιδιοκτησία ID:
| Ιδιοκτησία | Περιγραφή |
|---|---|
Subject | Μηνύματα Στόχος |
Body | Πλαίσιο κείμενο σώμα |
BodyHtml | HTML σώμα |
SenderName | Ονομασία αποστολής |
SenderEmailAddress | Εισαγωγή email address |
DisplayTo | Οι παραλήπτες εμφανίζουν το string |
DisplayCc | Cc παραλήπτες εμφανίζει στυλ |
DisplayBcc | Bcc παραλήπτες εμφανίζουν στυλ |
InternetMessageId | RFC 5322 Ανακοίνωση-ID |
MessageDeliveryTime | ΠΡΟΕΔΡΑΣΗ ΧΡΟΝΙΑΣ |
TransportMessageHeaders | Ράου RFC 5322 κεφαλές |
AttachFilename | Σύντομη προσθήκη φιλναμικού |
AttachLongFilename | Πλήρης σύνδεση φιλναμ |
AttachMimeTag | Τύπος MIME |
AttachContentId | Ετικέτες Content-ID |
Τύπος ιδιοκτησίας Κωδικός
Η PropertyTypeCode Ενότητα MAPI Κώδικα:
| Τύπος | Περιγραφή |
|---|---|
PtypString | Μοναδικό Σύνδεσμο |
PtypString8 | ΑΡΧΙΚΗ ΣΤΡΑΤΗ |
PtypInteger32 | 32-bit integer |
PtypInteger64 | 64-bit integer |
PtypBoolean | Μπόλεαν |
PtypTime | Ημερομηνία (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
- ΕΜΛ ΚΑΝΤΡΕΥΣΗ Μετατροπή μεταξύ μορφών
- CFB Κοντέντερ - χαμηλό επίπεδο διπλού εμπορευματικού δοχείου πρόσβασης