I'm now developing a simple IMAP-client. To recieve message body I'm using command "UID FETCH message-UID BODY.PEEK[]". The question is can I be sure that one of the server responses on the command will be "* message-sequence-number FETCH (UID message-UID BODY[] message-body)"? Or should I be ready to recieve any possible FETCH response (like with message envelope)? I know that I can recieve message flag updates in form of "* message-sequence-number FETCH (FLAGS flags)", I just ignore it now.
Of cause, I've read the standard rfc3501, but did not find out the answer.
You can't be sure that the message exists. But if it does exist, then the server has to send you a FETCH that includes both UID and BODY[], usually but not necessarily in that order. In practice it may also include FLAGS but nothing else.