I have a java program using Java Mail-1.
5 that fetch and process message(email) of Gmail(IMAP).
It works fine for most of the case, but for few messages when I try to get message_id using MimeMessage, it is giving me NULL. In that case I am not able to process the messages as messageID is unique for the messages.
String messageID = ((MimeMessage) msg).getMessageID(); //NULL for few messages.
Is there any other way to get message Id as I don't want to ignore such messages.
Messages are not required to have a Message-Id header. Most messages do. And in many cases, if a server receives a message without a Message-Id header, it will add one. Still, there are no guarantees. If you're depending on the Message-Id to uniquely identify a message, you need to have a fallback technique for the cases where the message doesn't have a Message-Id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With