Please be aware about UID of the message.
It is NOT an ID that never change!
If you move your message to another folder in your IMAP account, this UID WILL CHANGE.
So if your message has UID = 100 (in INBOX folder) and you move it to some subfolder and then back to INBOX, it's new UID in INBOX will be 101.