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

Free Support Forum - aspose.com

Extract the guid and name of a named mapi property using its tag in MapiMessage (Java)

I’m trying to find the name and guid of a named mapi property in a MapiMessage loaded from a pst file exported from Outlook.

Sample code:
import com.aspose.email.FolderInfo;
import com.aspose.email.MapiMessage;
import com.aspose.email.PersonalStorage;

public class Test2 {
public static void main(String[] args) {
PersonalStorage pst = null;
try {
// read message from pst
pst = PersonalStorage.fromFile(“outlook-1.pst”);
FolderInfo inboxFolder = pst.getRootFolder().getSubFolder(“Inbox”);
MapiMessage message = null;
for (MapiMessage message1: inboxFolder.enumerateMapiMessages()) {
message = message1;

boolean foundInNamedPropertyMapping = false;
int numberOfNamedProperties = 0;
for(Object tag: message.getProperties().getKeys()) {
if(message.getProperties().get_Item((Long)tag).isNamed()) {
if(message.getNamedPropertyMapping().getProperties().containsKey((Long)tag)) {
foundInNamedPropertyMapping = true;

System.out.println("Number of named mapi properties set in mapi message: " + numberOfNamedProperties);
System.out.println("Number of mappings found in MapiNamedPropertyMappingStorage: " + message.getNamedPropertyMapping().getProperties().size());
if(!foundInNamedPropertyMapping) {
System.out.println(“Could not find mapping for any of the named property tag”);
System.out.println(“Note: I’m trying to find the guid and name of the named mapi property from its tag”);
} catch (Exception e) {
} finally {
if(pst != null) {

outlook-1.pst file used can be found [here](https://drive.google.com/open?id=1KRCmqs7YQbBcrJIirboU_J_eIzN75rqQ).


I have observed your requirements and suggest you to please visit this documentation link for your convenience to fetch MAPI properties. If you encounter any issue then please share which property from message you desire to fetch and is not getting fetched.

I do not wish to fetch property value for a particular tag. I want to get the key of the property as guid and name instead of tag.

As you see in this snippet,

I wish to iterate through all the properties set, and try to find the name of the named MAPI property (0x8000 to 0xFFFE). Is there any possible way to find the name of the property from its tag.

I also tried this:


The value is null for most of the properties. Moreover the property descriptor returned by that method was PidTagPropertyDescriptor and not PidNamePropertyDescriptor or PidLidPropertyDescriptor.

My question is how to use MapiNamedPropertyMappingStorage to adress my requirement.

I’m trying to achieve something like this.

newPst = PersonalStorage.create(“new.pst”, 0);
MapiMessage newMapiMessage = new MapiMessage();
for(Object tag: message.getProperties().getKeys()) {
newMapiMessage.setProperty(message.getProperties().get_Item((Long)tag).getDescriptor(), message.getProperties().get_Item((Long)tag).getValue());

If you import this new pst into outlook, you can see that some properties like to are missing.
Note: I do not want to use com.aspose.email.MapiMessage.deepClone() as I need to change some property values and add new Properties.

In short, I would like to build a new MapiMessage object with just properties. (Which will be in either one of these data structures:

  • A Long tag and Object value — for type PidTagPropertyDescriptor
  • A UUID guid, String name and Object value — for type PidNamePropertyDescriptor
  • A UUID guid, Long id and Object value — for type PidLidPropertyDescriptor)

With these properties I will be using this method to set it to MapiMessage object.


When I do that for named properties, the pst could not be imported to outlook. It says “something went wrong”. If I skip named properties, it gets imported but some of the important fields are missing in the imported item.


I have shared sample code with you. This will help you to achieve your requirements. Please share feedback with us if there is still an issue.sample code.zip (734 Bytes)

Thank for your reply. The source code you have shared helped me get those name identifiers and guid.

Now, here is my next requirement.
I now have the properties and its identifiers read from an existing pst in this format:

  • A Long tag and Object value — for type PidTagPropertyDescriptor
  • A UUID guid, String name and Object value — for type PidNamePropertyDescriptor
  • A UUID guid, Long id and Object value — for type PidLidPropertyDescriptor

Using these I’m creating a new pst that could not be imported in outlook.
Source code: sample code.zip (17.3 KB)


Thank you for your feedback. I have tried opening the attached PST on my end and it got opened in MS Outlook on my end without any issue. For your kind reference, I have attached following snapshot as well. Can you please share which Outlook fails to open the provided PST on your end.

Do not just open it in Outlook. It will work fine.
Try to import that newly created PST (new.pst) into a mailbox in Outlook client. That’s where the issue occurred.
Outlook version: 2013


I have observed your comments. An issue with ID EMAILJAVA-34532 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

Thank you! I request you to address this as soon as possible. We need this to be resolved for our high priority release.


I like to inform as per our company policy, the first priority for investigation is given to the Paid Support i.e. Enterprise and Priority Support on first come first serve basis. After that the issues from normal support forum are scheduled for investigation on first come first serve basis. I request for your patience. We will share good news with you soon regarding your issue.

I understand, we will be expecting your response on this issue.


Sure, we will share good news with you soon.

Additional observation:
If we try to repair the newly formed pst file using outlook’s SCANPST.EXE, following error messages appear in logs.

    !!BTH node (nid=200024, hid=40), keys not ascending (dwkey=C2CB0000, dwkeyPrev=C2CB80B7)
  !!Contents Table for 8082, sub-object has invalid parent NID:
    irow = 0, RowID = 200024, ParNID = 0

      !!Message (nid=200024):
        Invalid parent (nid=0)
        Missing PR_MESSAGE_CLASS
        Missing PR_MESSAGE_FLAGS
        Missing PR_SEARCH_KEY
        Missing PR_CREATION_TIME

PFA repair log log.zip (932 Bytes)

I recently read the messages in this thread https://forum.aspose.com/t/corrupt-psts-generated/20428/22
Since that is a private thread I did not have access to the issue description but i believe both could be linked. So, can you brief me about the issue and the fix provided.


The thread that you have referred was related to Aspose.Email for .NET 16.1 and have been fixed in older version for provided PST. The nature of your issue could be different and may not be related to old issue. We will share good news with you as soon as the issue will be fixed.

Any update on this?


I have verified from our issue tracking system and regret to share that at present the issue is still unresolved. We will share the good news with you as soon as the issue will be fixed.

The issues you have found earlier (filed as EMAILJAVA-34532) have been fixed in this update.

@Adnan.Ahmad @mudassir.fayyaz,
The issue still exists for some items.
Please refer the attachment. source_code.zip (169.4 KB)