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 : abc-def@abc.com

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

for(MessageInfo messageInfo: messageInfos) {
MapiMessage mapiMessage = pst.extractMessage(messageInfo);
System.output.println(mapiMessage.getInternetMessageId());
}

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 “<abc-def@abc.com>” as internetMessageid.

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

@jiarongl,
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–admin@vault-prod.1bot2.info.pst.zip (888.9 KB)

The rfc message id I’m searching is
8d61a81c-545e-4263-bbb3-7caea5a62af3@vault-prod.1bot2.info

the src code snippet

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

PersonalStorageQueryBuilder builder = new PersonalStorageQueryBuilder();
builder.getMessageId()
    .contains("8d61a81c-545e-4263-bbb3-7caea5a62af3@vault-prod.1bot2.info", true);

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

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

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

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

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

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

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