I am using james server to send and receive emails. Consider the case when I sent out an email to a user, the user then replies with a email. This email will be saved into the inbox table of the mail database by james server.
However all emails sent by a user are saved in the inbox table. Im my case I would like to be able to recognise if an email is the reply to the email I sent previously or it is just a new message sent by a user?
Look for the post conditions of MimeMessage.reply. Per the documentation:
If setAnswered is set, the ANSWERED flag is set in this message.
The "Subject" field is filled in with the original subject prefixed with "Re:"(unless it already starts with "Re:"). The "In-Reply-To" header is set in the new message if this message has a "Message-Id" header. The current implementation also sets the "References" header in the new message to include the contents of the "References" header (or, if missing, the "In-Reply-To" header) in this message, plus the contents of the "Message-Id" header of this message, as described in RFC 2822.