+1 vote

Hi, I am using Mail.dll with Powershell. When I am moving a mail to another folder with MoveByUID(uid, folder), in some cases, I would like to mark it as read after that.

But it seems moving a mail changes its UID, so MarkMessageSeenByUID(uid) does not work anymore. I would have to read the new folder and try to find the mail.

This has to be a bug, right? If not I find this really odd because why have a unique identifier, if it changes simply changing location?

by

1 Answer

0 votes

It's not a bug. This is how IMAP protocol was designed.

UIDs make sense within a specific folder only - they are not globally unique.

To identify a message across all folders you need 3 variables: UID,
folder name and FolderStatus.UIDValidity.

(You can find more details on this here:
https://www.limilabs.com/blog/unique-id-in-imap-protocol)

When copying or moving a message, it gets a new UID.

MoveByUID method returns a newly assigned UID, if the server supports
UIDPLUS extension (Imap.Capabilities.UniqueIdPlus).

by (297k points)
...