Reputation: 439
I'm moving messages from the inbox folder to a new folder. After a while I need to move some of these messages(not all) to a new folder. The problem with this is that everytime I move a message the uid changes. How can I do this without moving the wrong message?
Upvotes: 0
Views: 201
Reputation: 11000
If your server supports UIDPLUS (nearly all do), and you yourself are moving or copying the messages, the server will give you the new UID when you copy or move it in the COPYUID response. You'll need to record this.
An example from the IMAP MOVE RFC6851:
C: a UID MOVE 42:69 foo
S: * OK [COPYUID 432432 42:69 1202:1229]
S: * 22 EXPUNGE
S: (more expunges)
S: a OK Done
The COPYUID
response includes the UIDVALIDITY
of the destination mail box, the UID set of the source messages, and the UID set of the destination messages.
If some other process is doing the moving, there's no way to guarantee the same message, and you'd have to track them based on their content (eg, the Message-ID header, the date time, a hash, etc.)
Upvotes: 1
Reputation: 446
You're "moving" also involves an INSERT into DB to keep track of UIDs? If yes, watch for autogenerated PKs.
Upvotes: 0