javax.mail fetching headers only and identifying mails

Hi,

I would like to fetch my emails through javax.mail by only reading the header fields like subject, from, to, etc. and load the contents (body and attachments) later.

For this to work I need a stable identifier for each message and attachment. I found the getContentID() method on MimeMessage and MimeBodyPart. Will these methods return the very same id for a certain message in different sessions as long as it stays on the server? Does this also work through POP3?

And folder.getMessages() returns an array or Message, but not of MimeMessage. Message doesn’t have the getContentID() method. How can I make sure, that the returned messages are always MimeMessages?

Thanks,
Marvin

content-ids are indeed used for identification of email messages. by design, they always stay the same. ofcourse there are bugs in software, but you are safe to assume the content-ids don’t change. (i found a bug in your typical exim server that b0rks everything, but let’s not go there).

but… why not write your own POP3 client? trivial, fun, and you’re in control of what happens.

Hehe, no time to write my own POP3 client ;D.

Thanks a lot for the quick answer.

Marvin