Make `IMailFolder.GetMessage()` return `IMimeMessage`
Author: ricardobossCreated Jul 20, 2025Updated Dec 7, 2025
Labelsenhancement
Is your feature request related to a problem? Please describe.
I'm currently trying to write unit tests for my services. One of these services uses MailKit to fetch some messages with attachments.
I can almost mock everything (using IImapClient, IMailFolder) except MimeMessage, because the Attachments property is not overridable.
Describe the solution you'd like
I'd like IMailFolder to return IMimeMessage on GetMessage/GetMessageAsync, so that I can return a mock implementation.
Describe alternatives you've considered
I considered simply creating a non-mocked instance of MimeMessage, which works fine. Still, it would be nice to be able to properly mock every aspect (for call counting, exception throwing, etc.)
Source: jstedfast/MailKit