Re: folder size and null pointer

Chris Burdess <[email protected]> Thu, 10 May 2012 08:24:44 +0100
Newsgroups gmane.comp.java.classpath.extensions.javamail
Message-ID <[email protected]>
Thufir wrote:
> How do you know *which* messages are available?
> 
> Of course, it's possible to load all messages from a folder, but when 
> using start and end parameters, how do you know whether the parameters 
> are valid?
> 
> 
> 
> getMessages
> 
> public Message[] getMessages(int start,
>                               int end)
>              throws MessagingException
> 
>      Returns the messages in the given range (inclusive).
> 
>      Parameters:
>          start - the number of the first message
>          end - the number of the last message
> 
> http://www.gnu.org/software/classpathx/javamail/javadoc/javax/mail/Folder.html#getMessages%28int,int%29

Message numbers will be in the range 1 to folder.getMessageCount(), and
you can get the message number of a known message with
message.getMessageNumber().