I'm building a mail client for Android and using JavaMail to get the messages via Imap Protocol. I'm saving the Message-Id header for every message I reveive and I came across a message that didn't contain any Message-Id header in it's original message but when I receive the message from Gmail via Imap I get a field called Envalope and this field happens to contain all the data I need including the Message-Id.
The problem is that I can't reach that Envelope object no matter what I do and I was wondering if someone has already done that and can throw some tips.
The original message came with the following content:
MIME-Version: 1.0
From: "Mailbox Support" <support@mailboxapp.com>
To: ******
Subject: Tips for Using Mailbox in Gmail
Content-Type: multipart/alternative;
boundary="----mailcomposer-?=_1-1369421942466"
------mailcomposer-?=_1-1369421942466
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
[some text]
------mailcomposer-?=_1-1369421942466
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
[Some rich text]
------mailcomposer-?=_1-1369421942466--
Thanks a lot
JavaMail uses the information in the IMAP ENVELOPE as the return values for methods such as getMessageID. Normally that will be the same data you would get using getHeader("Message-ID"), but if the Message-ID header is missing in the original message the server might "make up" a value to return in the ENVELOPE.