Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to get message_ID for MimeMessage

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.

like image 313
Ronak Avatar asked Sep 16 '25 18:09

Ronak


1 Answers

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.

like image 136
Bill Shannon Avatar answered Sep 19 '25 06:09

Bill Shannon