What client(s) are you using?
Let me paraphase your example slightly: with two messages in the inbox, move the second one to a folder called "XYZ", then delete the message in the inbox and delete the mesage in XYZ. This IMAP conversation would do that:
Code: Select all
1 select inbox
2 copy 2 XYZ
3 store 2 +flags \deleted
4 select XYZ
5 store 1 +flags \deleted
6 select inbox
7 store 1 +flags \deleted
Notice that IMAP doesn't have a "move" command, it only has copy and a mechanism for marking a message to be deleted.
So, what you're left with at the end of this is two messages in the INBOX, both of which have the \deleted flag set and one message in XYZ which has the \deleted flag set. I know this works because I created a user to test it and I did this (and this time I'm inclusing what the IMAP server reports):
Code: Select all
a select inbox
...
a OK [READ-WRITE] SELECT completed.
b fetch 1:* flags
* 1 FETCH (FLAGS (\Deleted))
* 2 FETCH (FLAGS (\Deleted))
b OK FETCH completed
c select XYZ
...
c OK [READ-WRITE] SELECT completed.
d fetch 1:* flags
* 1 FETCH (FLAGS (\Deleted $MdnSent))
d OK FETCH completed
The "$MdnSent" flag is set because we mustn't generate more than one MDN for a message so to avoid that we ensure that only one message has the "$MdnSent" flag unset. You don't need to worry about that, the point is that all three messages have the \deleted flag set. It doesn't matter if I'd "moved" message 1 or message 2, as far as the flags are concerned the end result is the same. I could fetch the contents of all three messages and discover which one had been copied (OK, I did that, it was the second one).
Now, if you have an IMAP client that displays one message in the inbox after all this then it must know something that the IMAP server doesn't: it must know which message was "moved" so that it can avoid displaying it.
If you look at the inbox with a MAPI client you'll see two messages and you'll see one message in the XYZ folder. That's because MAPI doesn't know about the \deleted flag.
Now, there is a minor white lie in all of this. For SWA we implemented an IMAP extension, there's an X-MOVE command: it actually does move a message from one folder to another. So if you move a message from the inbox to XYZ then you'll see that the message really has moved and that there are still only two copies of the message. SWA does something else as well; it cleans up (issues an EXPUNGE or a CLOSE) quite frequently so it doesn't leave messages lying around that are marked for deletion. As as result it is quite surprised (if software can be surprised) when it sees a message with the \deleted flag set -- in fact it tends to ignore that flag which catches me out from time to time.
Does that make what might be going on any clearer? Or is it just totally confusing? :-)
jch