We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set PR_SUBJECT_PREFIX_W and PR_NORMALIZED_SUBJECT_W properties

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 <span style=“font-family: “Courier New”;”>MapiMessage.<span style=“font-family: “Courier New”;”>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 ? “<span style=“font-family: “Courier New”;”>PR_NORMALIZED_SUBJECT_W not set” : "<span style=“font-family: “Courier New”;”>PR_NORMALIZED_SUBJECT_W: " + normalizedSubject.GetString());
}
}

Sample output:
PR_SUBJECT_W: FW: Some subject
PR_SUBJECT_PREFIX_W not set
<span style=“font-family: “Courier New”;”>PR_NORMALIZED_SUBJECT_W not set

Hi,


Thank you for posting your inquiry,

Could you please share a sample MSG file with us that has such property available in it? We couldn’t arrange one at our end to investigate the issue in presence of a sample file. We appreciate your cooperation in this regard.

There is no such file, I’m trying to create an empty .PST file (first <span style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 13px; background-color: rgb(255, 255, 255);”>using (PersonalStorage storage…) and than add message with subject, subject prefix and normalized subject to it.

<span style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 13px; background-color: rgb(255, 255, 255);”>
Then I open this newly created file (second <span style=“background-color: rgb(255, 255, 255); color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 13px;”>using (PersonalStorage storage…) and read message properties.

Hi,


Thank you for providing more details. It is observed that you are setting the properties which are not already present there. New properties should be added if not present already there in the collection. Following code adds one property PR_SUBJECT_W only, where as other two properties PR_SUBJECT_PREFIX_W and PR_NORMALIZED_SUBJECT_W are not added.

string path = “\”;<o:p></o:p>

using (PersonalStorage storage = PersonalStorage.Create(path + @"storage.pst", FileFormatVersion.Unicode))

{

FolderInfo folder = storage.RootFolder.AddSubFolder("folder name", "IPF.Note");

using (MapiMessage message = new MapiMessage())

{

message.Properties.Add(MapiPropertyTag.PR_SUBJECT_PREFIX_W, new MapiProperty(MapiPropertyTag.PR_SUBJECT_PREFIX_W, Encoding.Unicode.GetBytes("FW: "))); // PR_SUBJECT_PREFIX_W - NOT ADDED

message.Properties.Add(MapiPropertyTag.PR_NORMALIZED_SUBJECT_W, new MapiProperty(MapiPropertyTag.PR_NORMALIZED_SUBJECT_W, Encoding.Unicode.GetBytes("Normalized subject"))); // PR_NORMALIZED_SUBJECT_W - NOT ADDED

message.Properties.Add(MapiPropertyTag.PR_SUBJECT_W, new MapiProperty(MapiPropertyTag.PR_SUBJECT_W, Encoding.Unicode.GetBytes("FW: Some subject"))); // PR_SUBJECT_W - OK

folder.AddMessage(message);

}

}

using (PersonalStorage storage = PersonalStorage.FromFile(path + @"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());

}

}

This issue is logged under Id:EMAILNET-38672 for further investigation by the product team. You will be automatically notified once any update is received in this regard.

Hi,


We have investigated the issue in detail and observed that its not a bug of Aspose.Email. MessageInfo contains only the properties listed in Contents Table Template (Protocol Revision: 5.1) as follows:

  • PidTagImportance 0x0017
  • PidTagMessageClassW 0x001A
  • PidTagSensitivity 0x0036
  • PidTagSubjectW 0x0037
  • PidTagClientSubmitTime 0x0039
  • PidTagSentRepresentingNameW 0x0042
  • PidTagMessageToMe 0x0057
  • PidTagMessageCcMe 0x0058
  • PidTagConversationTopicW 0x0070
  • PidTagConversationIndex 0x0071
  • PidTagDisplayCcW 0x0E03
  • PidTagDisplayToW 0x0E04
  • PidTagMessageDeliveryTime 0x0E06
  • PidTagMessageFlags 0x0E07
  • PidTagMessageSize 0x0E08
  • PidTagMessageStatus 0x0E17
  • PidTagReplItemid 0x0E30
  • PidTagReplChangenum 0x0E33
  • PidTagReplVersionHistory 0x0E34
  • PidTagReplFlags 0x0E38
  • PidTagReplCopiedfromVersionhistory 0x0E3C
  • PidTagReplCopiedfromItemid 0x0E3D
  • PidTagItemTemporaryFlags 0x1097
  • PidTagLastModificationTime 0x3008
  • PidTagSecureSubmitFlags 0x65C6
  • PidTagLtpRowId 0x67F2
  • PidTagLtpRowVer 0x67F3
  • PidTagConversationId 0x3013