How to get the following values and what they mean in PST File via Java

Hello @MaazHussain,

The PST you provided doesn’t contain any categories. Additionally, there are no messages in this PST that have assigned categories.

Please note that you can retrieve the category-color mapping table only if the PST was created by Outlook and contains at least one item with an assigned category.

For PST files created using Aspose.Email, the category-color mapping table is not available, although you can still add items with assigned categories. This limitation exists due to the lack of a publicly available specification for implementing such a table.

EMAILJAVA-35352 ---- Status : Resolved

@sergey.vivsiuk / @margarita.samodurova The status is shown as resolved can you let us know in which version we can find it?

@MaazHussain,

This will be available in version 25.3, expected to be released early next month.

1 Like

@margarita.samodurova The requirement which we had was to fetch the limit of mails, was to extract the limit of messages from the folder and not the list of mails in that range.

So if say a folder has 500 emails and from 0 - 50 there are 20 unread emails, the fix now returns 20 emails.
But what we needed was when we provide 50 as the limit it has to return the first 50 unread emails instead of 20 which is getting returned now, is is possible to provide this fix?

folder.getContents(queryBuilder.getQuery()), start, limit);

@MaazHussain
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): EMAILJAVA-35364

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks @sergey.vivsiuk .

Just to confirm again the case so we are on the same page.

The required fix is when i enter the start value as 0 and limit as 50 it should return the top 50 mails matching that condition. and if later i send the start value as 51 and then limit as 50 it should return from the 51st mail matching that condition till the limit.

Hello @MaazHussain ,

Thank you for the detailed explanation. We were able to reproduce the issue on a larger messages set. A ticket has been opened, and we’re actively working on a fix.

@sergey.vivsiuk

I also found the issue to resurface while trying to perform mark as read/ unread action on a PST file.

This is the code im trying. Can you please have this checked and let me know, im facing the same error for most of the pst files, it was working fine in the start but after a point of time I started getting this error and its constant from then on.


 markAsReadUnread(pst, "AAAAAHA09Qzhep5Mt2K+2wvBQ/rkACAA", true);


public static void markAsReadUnread(PersonalStorage pst, String messageId, boolean isUnread) {
        MapiMessage msg = pst.extractMessage(messageId);
        MapiPropertyCollection updatedProperties = new MapiPropertyCollection();

        long flags = msg.getFlags();
        if (isUnread) {
            flags &= ~MapiMessageFlags.MSGFLAG_READ;
        } else {
            flags |= MapiMessageFlags.MSGFLAG_READ;
        }

        updatedProperties.add(new MapiProperty(MapiPropertyTag.PR_MESSAGE_FLAGS, intToPT_LONG((int) flags)));

        pst.changeMessage(messageId, updatedProperties);
        pst.dispose();
    }

Error:

Exception in thread "main" class com.aspose.email.system.exceptions.ArgumentException: An element with the same key already exists in the dictionary.
com.aspose.email.system.collections.generic.Dictionary.addItem(Unknown Source)
com.aspose.email.zfs.a(SourceFile:540)
com.aspose.email.zfs.h(SourceFile:494)
com.aspose.email.zfs.<init>(SourceFile:85)
com.aspose.email.zahs.b(SourceFile:1004)
com.aspose.email.zavw.a(SourceFile:1261)
com.aspose.email.PersonalStorage.changeMessage(SourceFile:2125)
com.zoho.trident.ZPSTMailActions.markAsReadUnread(ZPSTMailActions.java:22)
com.zoho.trident.Main.main(Main.java:63)
	at com.aspose.email.system.collections.generic.Dictionary.addItem(Unknown Source)
	at com.aspose.email.zfs.a(SourceFile:540)
	at com.aspose.email.zfs.h(SourceFile:494)
	at com.aspose.email.zfs.<init>(SourceFile:85)
	at com.aspose.email.zahs.b(SourceFile:1004)
	at com.aspose.email.zavw.a(SourceFile:1261)
	at com.aspose.email.PersonalStorage.changeMessage(SourceFile:2125)
	at com.zoho.trident.ZPSTMailActions.markAsReadUnread(ZPSTMailActions.java:22)
	at com.zoho.trident.Main.main(Main.java:63)

Convo.pst.zip (88.8 KB)

@MaazHussain,

Thank you for bringing this to our attention. We’ll take a closer look at the issue and get back to you as soon as we have more info.

Sure @margarita.samodurova, Had missed to add the error, have added it now, incase if it helps.

@MaazHussain,

Thank you for the update.

@MaazHussain
We have reproduced the ArgumentException error while applying changes to the PST.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): EMAILJAVA-35367

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@sergey.vivsiuk / @margarita.samodurova is there a provision to getContents of a folder in a sorted order? Like all mails to be given in Ascending order or in Descending Order?

@MaazHussain,

The ComparisonField.orderBy(boolean ascending) method allows to sort emails in ascending/descending order based on the criteria specified by MailQueryBuilder.

MailQueryBuilder builder = new MailQueryBuilder();
builder.getSubject().contains("Report");

// Sort by subject in ascending order
builder.getSubject().orderBy(true);

MessageInfoCollection messageInfos = inbox.getContents(builder.getQuery());

How can i do the same when i have to sort the mails i receive itself in that order without any builder?

For Example Something like this is this possible? So that i can get the list of mails in the order i require?

folder.getContents(start, limit, boolean ascending);
folder.getContents(start, limit, false);

The getContents() method returns messages in the order they are stored, but it does not support sorting directly. Therefore, sorting must be performed manually after extraction. This can be done without using Aspose.Email.

@margarita.samodurova Any update on the below issues?

EMAILJAVA-35364 ---- Status : Resolved
EMAILJAVA-35367 ---- Status : Open

When will it be released and when will the other be fixed?

Hello @MaazHussain ,

The issue EMAILJAVA-35367 has been resolved, and the fix will be released in the upcoming Aspose.Email for Java 25.4 version on May 5–6.

Ok Thanks for the update @sergey.vivsiuk

@MaazHussain,

You are welcome.