• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java-Mail  RSS feed

 
Suhani arora
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi To ALL ..
This is SUHANI again..
Frnds Every Message has a unique field MESSAGE ID
Any body please tell me how could i get this MESSAGE ID from Java


Thanks In Advance
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome Suhani,
This is not a question related to webservices. I am moving question to our java-mail forum, folks there might help you.
 
Seetesh Hindlekar
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Message message[] = folder.getMessages();
message[i].getMessageNumber()

Rgds,

Seetesh
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16007
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Seetesh Hindlekar:
Message message[] = folder.getMessages();
message[i].getMessageNumber();


Sorry, but this is the wrong answer. This does not give you the message's unique ID, it just gives you the number of the message in the folder. If you look later and messages have been deleted / added to the folder, the numbers will have changed.

You can get the Message-ID header using getHeader:

String id = message.getHeader("Message-ID");

Note that this is not 100% reliable; I've tried to use it in a real world situation, and not all mail servers add a Message-ID header to the message, even though the SMTP specification says it is required.

So don't count on it that all mail messages have a unique ID.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!