Get email field "PR_CONVERSATION_INDEX"

In aspose email - java version

We’re trying to pull PR_CONVERSATION_ID from emails. How can we get this value?
We have it as a mailmessage and mapimessage but can’t find it either way

It looks like this line could get us thread index, but from my understanding that’s not necessarily the same thing as PR_CONVERSATION_INDEX
mapiMessage.getHeaders().getDecodedValue(“Thread-Index”);

edit:
This also just threw null and crashed out
byte[] conversationId = mapiMessage.getProperties().get_Item(MapiPropertyTag.PR_CONVERSATION_INDEX).getData();

Hello @User65432,

Can you send us examples of problematic messages (eml and msg)?
Thanks.

FW_ Treasury Announces Marketable Borrowing Estimates.zip (58.2 KB)

This is an example, but we’re looking for the code that should apply to any email - We need the conversation index for client data

Hello @User65432,

The MailMessage “Thread-Index” header value is a MapiMessage Conversation Index value (PR_CONVERSATION_INDEX MAPI property) in Base64 encoded form.

For example:

String fileName = "FW_ Treasury Announces Marketable Borrowing Estimates.msg";
MapiMessage msg = MapiMessage.load(fileName);
if (msg.getProperties().containsKey(MapiPropertyTag.PR_CONVERSATION_INDEX)) {
    byte[] ind = msg.getProperties().get_Item(MapiPropertyTag.PR_CONVERSATION_INDEX).getData();
    System.out.println("MAPI INDEX: " + java.util.Base64.getEncoder().encodeToString(ind));

    // convert MapiMessage to MailMessage and get header values
    MailMessage eml = msg.toMailMessage(new MailConversionOptions());
    System.out.println(eml.getHeaders().get_Item("Thread-Topic"));
    System.out.println("MAIL INDEX: " + eml.getHeaders().get_Item("Thread-Index"));
}

Thank you
I believe this worked, we’ll do more testing and get back to this thread if we encounter issues when we push more data through it

For future devs looking for this value

using the mapimessage method – you probably don’t want to base64 encode the value. Instead get the byte[], then encode it to hex string and uppercase the result to match the more standard PR_CONVERSATION_INDEX value you’d expect