Ahh. No worries. Mistakes are easily made. And easily corrected if and when you ask the right people.
:-) Regards, Pierre Smits *ORRTIZ.COM <http://www.orrtiz.com>* Services & Solutions for Cloud- Based Manufacturing, Professional Services and Retail & Trade http://www.orrtiz.com On Tue, Oct 21, 2014 at 3:50 PM, Girivaraprasad Nambari < girinamb...@gmail.com> wrote: > Thank you Bernd & Pierre for your time and sharing knowledge! > > I am not sure why I picked getMessageNumber() instead of getMessageID(), > may be lack of understanding. > > I read some where that one of the case for messageID NOT unique is create a > copy of email. > > Name is interesting approach. Will check both of these tonight. > > Thank you, > Giri > > > On Tue, Oct 21, 2014 at 4:39 AM, Bernd Waibel <bwai...@intarsys.de> wrote: > > > Hello Pierre, > > > > sorry, no, not generated by james. So this is not a james bug. > > > > It seems that a lot of spam senders just do not set the id, and some > older > > clients like outlook 2003. > > This is conform to RFC, because the id SHOULD exist. But do not need to. > > > > In our code we use the id, e.g. for logging. > > > > ciao > > Bernd > > > > > > -----Ursprüngliche Nachricht----- > > Von: Pierre Smits [mailto:pierre.sm...@gmail.com] > > Gesendet: Dienstag, 21. Oktober 2014 10:02 > > An: James Users List > > Betreff: Re: Does james re-use messageID? [unsigned] > > > > Hi Bernd, > > > > You stated that you see a lot of mails without a message id. Are that > > mails/messages generated by James? Or is the statement to be considered > as > > 'in general'? > > > > If it is pertaining to James, then we should consider this a bug and a > > JIRA could be registered. > > > > Regards > > > > Pierre Smits > > > > *ORRTIZ.COM <http://www.orrtiz.com>* > > Services & Solutions for Cloud- > > Based Manufacturing, Professional > > Services and Retail & Trade > > http://www.orrtiz.com > > > > On Tue, Oct 21, 2014 at 8:57 AM, Bernd Waibel <bwai...@intarsys.de> > wrote: > > > > > Hi Giri, > > > > > > your question is somehow unclear to me. So I try to clear some things > up. > > > There is a "message ID" and a "message number". > > > > > > According to RFC every mail SHOULD have a Header-Field "message-id". > > > (See https://tools.ietf.org/html/rfc2822 Chapter 3.6.4). > > > But "in the wild" we observe a lot of mails without a message id. > > > The "message number" is just the number of a mail in a folder. > > > So if you delete messages in a folder, you may get new message > > > numbers. Or maybe if the get sorted. > > > > > > If you would like to identify a message, you could use message-id, but > > > you could not trust this header field to be set. > > > So we do fix that in our own implementation: (our code, feel free to > > use): > > > /** > > > * An id suitable for logging etc. > > > * > > > * @param mail > > > * @return > > > */ > > > static public String getId(Mail mail) { > > > try { > > > // rfc2822: every message SHOULD have a > > > "Message-ID:" field. > > > // But not need to. Outlook 2003 may miss the > id. > > > String id = mail.getMessage().getMessageID(); > > > if (id == null || id.trim().isEmpty())) { > > > id = mail.getName(); > > > } > > > return id; > > > } catch (MessagingException e) { > > > return mail.getName(); > > > } > > > } > > > We use the "getName" as fallback, which ist part of the > > > org.apache.mailet.Mail API. > > > This seems to work good, we did not have mails without a name till now. > > > > > > But the name need NOT to be unique. E.g. if you "copy" a mail in your > > > programm, it may have the same name. > > > To me it seems there is not a "always unique" number. > > > The message-id is very near to "always unique", if it exists. > > > The "name" may be next to that, it seems always to be be there. > > > The "messagenumber" is only temporary unique. > > > > > > Btw: This is not part of "james", is it part of the Java Mail API, > > > developed by Sun, years ago. > > > > > > For the java classes you mentioned, you may have a look at the source > > > code of this classes: > > > javax.mail.Message: > > > /** > > > * Get the Message number for this Message. > > > * A Message object's message number is the relative > > > * position of this Message in its Folder. Note that the message > > > * number for a particular Message can change during a session > > > * if other messages in the Folder are deleted and expunged. <p> > > > * > > > * Valid message numbers start at 1. Messages that do not belong > > > * to any folder (like newly composed or derived messages) have 0 > > > * as their message number. > > > * > > > * @return the message number > > > */ > > > public int getMessageNumber() { > > > return msgnum; > > > } > > > > > > javax.mail.internet.MimeMessage (extends javax.mail.Message) > > > /** > > > * Returns the value of the "Message-ID" header field. Returns > > > * null if this field is unavailable or its value is absent. <p> > > > * > > > * The default implementation provided here uses the > > > * <code>getHeader</code> method to return the value of the > > > * "Message-ID" field. > > > * > > > * @return Message-ID > > > * @exception MessagingException if the retrieval of this field > > > * causes any exception. > > > * @see javax.mail.search.MessageIDTerm > > > * @since JavaMail 1.1 > > > */ > > > public String getMessageID() throws MessagingException { > > > return getHeader("Message-ID", null); > > > } > > > > > > Good luck, > > > Bernd > > > > > > -----Ursprüngliche Nachricht----- > > > Von: Girivaraprasad Nambari [mailto:girinamb...@gmail.com] > > > Gesendet: Dienstag, 21. Oktober 2014 07:35 > > > An: James Users List > > > Betreff: Does james re-use messageID? > > > > > > Hi Everyone, > > > > > > I have observed an interesting scenario today with James messageID, I > > > received few hundred emails and all emails got incremented messageID. > > > > > > Today I deleted few old emails. The emails I received after cleaning > > > up old emails got old message Id's. > > > > > > 1) Does james re-use messageID? > > > If yes, is there anyway we can disable this feature? > > > > > > In my code I am using following statement to retrieve message ID: > > > MimeMessage msg = (MimeMessage) cMsg; int messageNumber = > > > msg.getMessageNumber(); > > > > > > As per mail specification, shouldn't messagenumber be unique? > > > > > > Any help appreciated. > > > > > > Thank you, > > > Giri > > > > > >