When does folder.getMessages() get the messages?
The JavaDoc for folder.getMessages says:
....Folder implementations are expected to provide light-weight Message objects, which get filled on demand. .....
A Message object obtained from a folder is just a lightweight reference to the actual message. The Message is 'lazily' filled up (on demand) when each item is requested from the message. Note that certain folder implementations may return Message objects that are pre-filled with certain user-specified items.