How to update message properties in PST without extraction

Hi,


Is it possible to update message properties without extracting the complete message first?

Hi Robert,

Thank you for writing to Aspose support team.

FolderInfo.ChangeMessages can be used to update PST messages without extracting them. Please give it a try and share the feedback.

string dataDir = path + "test.pst";
PersonalStorage personalStorage = PersonalStorage.FromFile(dataDir);
FolderInfo inbox = personalStorage.RootFolder.GetSubFolder("Inbox");
MessageInfoCollection messages = inbox.GetContents();
IList changeList = new List();

foreach (MessageInfo messageInfo in messages)
{
    changeList.Add(messageInfo.EntryIdString);
}

// Compose the new properties
MapiPropertyCollection updatedProperties = new MapiPropertyCollection();
updatedProperties.Add(MapiPropertyTag.PR_SUBJECT_W, new MapiProperty(MapiPropertyTag.PR_SUBJECT_W, Encoding.Unicode.GetBytes("New Subject")));
updatedProperties.Add(MapiPropertyTag.PR_IMPORTANCE, new MapiProperty(MapiPropertyTag.PR_IMPORTANCE, BitConverter.GetBytes((long)2)));

// update messages having From = "someuser@domain.com" with new properties
inbox.ChangeMessages(changeList, updatedProperties);

You may also visit here for more samples:


Updating Message Properties in a PST File
Updating Custom Properties in a PST File