I'm not sure how to do it with ImapX, but the IMAP protocol allows you to FETCH the ENVELOPE of a message, which is essentially a pre-parsed set of the most important headers of a message (including the Message-ID).
That said, a Message-ID is not guaranteed to be unique, so blindly deleting messages with identical Message-IDs is dangerous.
That said, a Message-ID is not guaranteed to be unique, so blindly deleting messages with identical Message-IDs is dangerous.