Can't search RFC message id in a PST file

i’m using aspose email 20.5.3
sample code to find the message with rfc message id :

FolderInfo folder = pst.getRootFolder().getSubFolder(“Inbox”);
PersonalStorageQueryBuilder builder = new PersontalStorageQueryBuilder();
builder.getMessageId().contains(“”, true)
MessageInfoCollection messageInfos = folder.getContents(builder.getQuery());

for(MessageInfo messageInfo: messageInfos) {
MapiMessage mapiMessage = pst.extractMessage(messageInfo);

When I didn’t use the query, it shows all the messages and after converting to mapi Message I can see it’s listed as “<>” as internetMessageid.

But when I add the query, the search result is 0. I’m wondering if i’m using the API correctly.

Thank you for the issue description. Could you share the PST file to investigate the problem, please? You can compress the file to a ZIP archive and upload it. Another way is to share a link to the PST file in Google Drive or Dropbox.

Also, please check the issue with the latest version of Aspose.Email.

Here’s the pst file in the attachmentTest_Matter_wxn8c01wl2– (888.9 KB)

The rfc message id I’m searching is

the src code snippet

FolderInfo folder = pst.getRootFolder().getSubFolder("Inbox");

PersonalStorageQueryBuilder builder = new PersonalStorageQueryBuilder();
    .contains("", true);

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

List<MailMessage> messageList = new ArrayList<>();
for (MessageInfo messageInfo : messageInfos) {
  MapiMessage mapiMessage = pst.extractMessage(messageInfo);

Thank you for the PST file example. I reproduced the problem and received the same results. I have logged the issue in our tracking system with ID EMAILJAVA-34857. Our development team will investigate it. You will be notified when the issue is fixed.

Our development team investigated the issue. The PR_INTERNET_MESSAGE_ID_W and PR_INTERNET_MESSAGE_ID properties are missed in the messages from the original PST file. These properties are used to filter messages by MessageId.

But if this property is missed then the InternetMessageId will be extracted from the PR_TRANSPORT_MESSAGE_HEADERS_W property. The PR_TRANSPORT_MESSAGE_HEADERS_W property cannot be used to filter messages due to performance degradation.

Unfortunately we only have PR_TRANSPORT_MESSAGE_HEADERS_W in the data and need to filter out based on the message id. The only workaround I can think of is to iterate through all the MapiMessage and find the one with internet message id same as what I specified. That also looks clumsy.

I’m concerned about how much performance degradation there would be if you guys can provide an option to filter PR_TRANSPORT_MESSAGE_HEADERS_W. If that’s faster than the workaround, that would be acceptable actually.

I asked our development team to investigate this question.

Thanks. You mentioned if The PR_INTERNET_MESSAGE_ID_W and PR_INTERNET_MESSAGE_ID are missing, the InternetMessageId is extracted from PR_TRANSPORT_MESSAGE_HEADERS_W.

Another option is that when you read the pst file and parse it , if PR_INTERNET_MESSAGE_ID_W and PR_INTERNET_MESSAGE_ID are missing, you change the logic that they are automatically filled in with PR_TRANSPORT_MESSAGE_HEADERS_W if it’s not empty. So that later when it’s either parsed to MapiMessage or filtered by message id, it can still use the field PR_INTERNET_MESSAGE_ID_W and PR_INTERNET_MESSAGE_ID. No code change needed in filtering then.

Thank you for your suggestion. I passed it to our development team.

The fix will be released in Aspose.Email 21.4.

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