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

@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.

@margarita.samodurova / @sergey.vivsiuk

Do we have any plans on supporting mark as read and unread for multiple mails at once in a folder?
As of now I have to do it for single mails like this.

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);
    }

I would like to pass array of [messageIds] and would like it to update for the whole. Cause doing for each single mail is taking a lot of time when we would like to mark more than 50 - 100 mails as read or unread.

Hello @MaazHussain,

We will explore the possibility of introducing a method that supports batch updates of message flags with improved performance.

A corresponding ticket has been created in our internal tracking system to investigate this feature further.

Issue ID(s): EMAILJAVA-35374
1 Like

Hello @margarita.samodurova we need the same support for .Net too, please loop me on this update

Hello @Devishree.

All feature requests and enhancements made for Java are also tracked for .NET and vice versa. The .NET ticket is already in place.