public static void Run()
{
// ExStart:GetMAPIProperty
// The path to the File directory.
string dataDir = RunExamples.GetDataDir_Outlook();
// Load from file
MapiMessage msg = MapiMessage.FromFile(dataDir + @"message.msg");
string subject;
// Access the MapiPropertyTag.PR_SUBJECT property
MapiProperty prop = msg.Properties[MapiPropertyTag.PR_SUBJECT];
// If the property is not found, check the MapiPropertyTag.PR_SUBJECT_W (which is a // Unicode peer of the MapiPropertyTag.PR_SUBJECT)
if (prop == null)
{
prop = msg.Properties[MapiPropertyTag.PR_SUBJECT_W];
}
// Cannot found
if (prop == null)
{
Console.WriteLine("No property found!");
return;
}
// Get the property data as string
subject = prop.GetString();
Console.WriteLine("Subject:" + subject);
// Read internet code page property
prop = msg.Properties[MapiPropertyTag.PR_INTERNET_CPID];
if (prop != null)
{
Console.WriteLine("CodePage:" + prop.GetLong());
}
// ExEnd:GetMAPIProperty
}
}