Hi, i am trying to figure out how to properly set properties PR_SUBJECT_PREFIX_W and PR_NORMALIZED_SUBJECT_W on a message in a newly created PST file.
So far I've tried using Subject property:
message.Subject = "FW: Some subject";
And setting all three related MAPI properties:
message.SetProperty(new MapiProperty(0x003D001F, Encoding.Unicode.GetBytes("FW: "))); // PR_SUBJECT_PREFIX_W
message.SetProperty(new MapiProperty(0x0E1D001F, Encoding.Unicode.GetBytes("Some subject"))); // PR_NORMALIZED_SUBJECT_W
message.SetProperty(new MapiProperty(0x0037001F, Encoding.Unicode.GetBytes("FW: Some subject"))); // PR_SUBJECT_W
After I save and reopen PST file there is no subject prefix and normalized subject in message properties
Here is my sample code:
using (PersonalStorage storage = PersonalStorage.Create(@"c:\storage.pst", FileFormatVersion.Unicode))
{
FolderInfo folder = storage.RootFolder.AddSubFolder("folder name", "IPF.Note");
using (MapiMessage message = new MapiMessage())
{
// using MapiMessage.Subject property:
//message.Subject = "FW: Some subject";
// directly setting Mapi properties:
message.SetProperty(new MapiProperty(0x003D001F, Encoding.Unicode.GetBytes("FW: "))); // PR_SUBJECT_PREFIX_W
message.SetProperty(new MapiProperty(0x0E1D001F, Encoding.Unicode.GetBytes("Some subject"))); // PR_NORMALIZED_SUBJECT_W
message.SetProperty(new MapiProperty(0x0037001F, Encoding.Unicode.GetBytes("FW: Some subject"))); // PR_SUBJECT_W
folder.AddMessage(message);
}
}
using (PersonalStorage storage = PersonalStorage.FromFile(@"c:\storage.pst"))
{
foreach (MessageInfo message in storage.RootFolder.GetSubFolder("folder name").EnumerateMessages())
{
MapiProperty subject = message.Properties[0x0037001F];
Console.WriteLine(subject == null ? "PR_SUBJECT_W not set" : "PR_SUBJECT_W: " + subject.GetString());
MapiProperty subjectPrefix = message.Properties[0x003D001F];
Console.WriteLine(subjectPrefix == null ? "PR_SUBJECT_PREFIX_W not set" : "PR_SUBJECT_PREFIX_W: " + subjectPrefix.GetString());
MapiProperty normalizedSubject = message.Properties[0x0E1D001F];
Console.WriteLine(normalizedSubject == null ? "PR_NORMALIZED_SUBJECT_W not set" : "PR_NORMALIZED_SUBJECT_W: " + normalizedSubject.GetString());
}
}
Sample output:
PR_SUBJECT_W: FW: Some subject
PR_SUBJECT_PREFIX_W not set
PR_NORMALIZED_SUBJECT_W not set