Hello,
Unfortunately, it's not that simple in IMAP. IMAP protocol's unique ID has no relation at all to MessageId or EnvelopeId. To make it even more complicated, a delivery status notification (DSN) is not actually a response, and can't be searched for using MessageId or EvenlopeId. Overall, there is no straightforward way to simply obtain a unique ID of a DSN based on the message ID.
Instead, a different process is usually used: The application checks Inbox for new messages. For each new message, it determines whether it's a delivery status notification. If it is, the application parses it and tries matching the DSN against known MessageId or EnvelopeId of a sent messages.