PersonalStorage.ExtractProperty :: Get MessageClass

Hello,
PersonalStorage.ExtractProperty(entryID, Tag?!)
I need to get the MessageClass without extracting the whole message, (having entryID)
So shall I use ExtractProperty?
And then how to get the MessageClass?
I need to obtain the item type (message/contact/calendar)

I see there are a few properties (6 similar ones), any idea which one to use?

Dim AA As MapiProperty = MyStorage.ExtractProperty(entryID, MapiPropertyTag.PR_MESSAGE_CLASS)

Value of type ‘String’ cannot be converted to ‘1-dimensional array of Byte’
I have the entryID as string…

The whole code is:
Using MyStorage As PersonalStorage = PersonalStorage.FromBlah…
Dim AA As MapiProperty = MyStorage.ExtractProperty(entryID, MapiPropertyTag.PR_MESSAGE_CLASS)

(not looping through all messages - all your samples are getting entryID as byte in loop from msg)
SaveMessageToStream accepts entryID as string, but not the ExtractProperty! :frowning:

And no idea if this is correct:
Dim AA As MapiProperty = MyStorage.ExtractProperty(Convert.FromBase64String(entryID), MapiPropertyTag.PR_ORIG_MESSAGE_CLASS)
But AA will always be null

Untitled.png (15.6 KB)

@australian.dev.nerds

Could you please share some more detail about your requirement along with sample input storage file along with code example that you are using? We will investigate the issue and provide you information on it.

1 Like

Sure, consider it as a ExtractProperty sample, need to know how it works…

Detailed: You already provided a solution to get the message item type here:

But this requires the message to evaluate I need to get the PersonalStorage (pst/ost) item type before extracting the message (SaveMessageToStream)
So I guess I should use ExtractProperty and pass the entryID to get the item type (MessageClass)?
If I’m right please kindly provide a sample to achieve it.

@australian.dev.nerds

A ticket has been logged as EMAILNET-40838 for this requirement. You will be informed once there is an update available on it.

@australian.dev.nerds

We have closed the ticket EMAILNET-40838. The MessageInfo already contains the MessageClass property. When MessageInfo initialized, the whole message is not extracted.

foreach (var folder in pst.RootFolder.EnumerateFolders())
{
    if (folder.ContainerClass == "IPF.Contacts")
    {
        foreach (var messageInfo in folder.EnumerateMessages())
        {
            if (messageInfo.MessageClass == "IPM.Contacts")
            {
                // do something...
            }
        }
    }
}

And, if you want, you can call the ExtractProperty to get the MessageClass:

foreach (var folder in pst.RootFolder.EnumerateFolders())
{
    if (folder.ContainerClass == "IPF.Contacts")
    {
        foreach (var entryIdString in folder.EnumerateMessagesEntryId())
        {
            var messageClassProperty = pst.ExtractProperty(Convert.FromBase64String(entryIdString),
                KnownPropertyList.MessageClass.Tag); // or use MapiPropertyTag.PR_MESSAGE_CLASS as alternative

            if (messageClassProperty != null && messageClassProperty.GetString() == "IPM.Contacts")
            {
                // do something...
            }
        }
    }
}