We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Message id and thread id is different

Message id and thread id is different when loaded .msg file while same message if synced from Exchange have different message id and conversation id.

What is the solution for this?

How to get message id and conversation id which will be unique?

@ajaydarekar,

Could you please share the .msg file and the sample code that you are running. This will us in reproducing the issue and assisting you further.

AAAAABa ykqh0G9Fk3TfP2Vi RAEAiAA.zip (8.3 KB)

MailMessage msg = MailMessage.load(“D:\extract\AAAAABa+ykqh0G9Fk3TfP2Vi+RAEAiAA.msg”, new MsgLoadOptions());
System.out.println("Subject: "+msg.getSubject());
System.out.println("Id: "+msg.getMessageId());

@ajaydarekar,

Please share the code which you use to sync and retrieve MessageId from Exchange as well.

private static EPEmailMessage mapFromEmailMessage(microsoft.exchange.webservices.data.core.service.item.EmailMessage emailMessage, EPEmailFolder emailFolder, boolean fetchAttachmentContent) throws Exception {

	System.out.println("Conversation id : " + emailMessage.getConversationId().getUniqueId());
	System.out.println("Message id : " + emailMessage.getId().getUniqueId());
	//System.out.println("inte msg id : " + emailMessage.getInternetMessageId());
	EPEmailMessage mappedMessage = new EPEmailMessage();
	mappedMessage.setSourceConversationId(emailMessage.getConversationId().getUniqueId());
	mappedMessage.setSourceMessageId(emailMessage.getId().getUniqueId());
	mappedMessage.setInternetMessageId(emailMessage.getId().getUniqueId());
	mappedMessage.setMessageType(EPEmailSourceType.EXCHANGE);

	mappedMessage.setSubject(emailMessage.getSubject() != null ? emailMessage.getSubject() : "");

	MessageBody messageBody = emailMessage.getBody();
	if (messageBody.getBodyType() == BodyType.HTML) {
		mappedMessage.setBodyHTML(messageBody.toString());
	} else {
		mappedMessage.setBodyText(messageBody.toString());
	}

	mappedMessage.setBodyPreview(BodyPreviewBuilder.buildBodyPreview(messageBody));
	mappedMessage.setMimeContent(emailMessage.getMimeContent().getContent());

	mappedMessage.setSizeInBytes(emailMessage.getSize());

	EPEmailFolderCategory emailFolderCategory = emailFolder.getEmailFolderCategory();

	boolean isDrafted = emailFolderCategory == EPEmailFolderCategory.DRAFT_SYSTEM || emailFolderCategory == EPEmailFolderCategory.DRAFT_USER;

	mappedMessage.setReceivedOn(isDrafted ? emailMessage.getDateTimeCreated() : emailMessage.getDateTimeReceived());
	mappedMessage.setSortDate(isDrafted ? emailMessage.getDateTimeCreated() : emailMessage.getDateTimeReceived());
	mappedMessage.setSentOn(emailMessage.getDateTimeSent());

	mappedMessage.setSentItem(emailMessage.getIsFromMe() || emailFolderCategory == EPEmailFolderCategory.SENT_SYSTEM
			|| emailFolderCategory == EPEmailFolderCategory.SENT_USER);

	mappedMessage.setFlags(ExchangeMapper.buildByExchangeEmailMessage(emailMessage, emailFolder.getEmailFolderCategory()));

	mappedMessage.getLabels().add(emailFolder.getDisplayName().toUpperCase());

	mappedMessage.setReplyTo(getReplyToAddresses(emailMessage));
	mappedMessage.setFrom(getSenderAddress(emailMessage));
	mappedMessage.setTo(getToAddresses(emailMessage));
	mappedMessage.setBcc(getBccAddresses(emailMessage));
	mappedMessage.setCc(getCcAddresses(emailMessage));
	
	return mappedMessage;
}

@ajaydarekar,

You are using Microsoft EWS to parse the email. Please use EWS client provided by Aspose.Email for Java. Please also make sure that you are using the latest version of Aspose.Email for Java API.

That is ok, Using aspose or microsoft ews for reading mail from exchange server is returning same result. I can fetch conversation id and message id while reading mails from Exchange server by either way.

My problem is, I am unable to read conversation id and message id if “.eml” or “.msg” file is loaded using aspose email library. I get different message id while there is not getter method to get conversation id.

@ajaydarekar,

Please share the id’s that you get by using Aspose.Email for Java EWS client against the email that you shared with us. We will investigate this further by looking into the file you attached.