Reputation: 14813
In MailKit,
You can fetch the IMessageSummary (containing the specified headers and the full message) for several messages with the following
ImapFolder folder;
List<UniqueId> uids;
var messageSummaries = folder.Fetch(uids,
MessageSummaryItems.Full,
new HashSet<string>{"X-Mailer"});
If a pass an empty HashSet<string>
, I get a System.ArgumentException: The set of header fields cannot be empty
.
How can I fetch all headers available ?
Note: I know that I could get the headers on each message, one by one, but it is too slow to match my performance needs.
Upvotes: 1
Views: 1018
Reputation: 14813
As MailKit is open-source, I just modified the code of ImapFolderFetch
to handle the fetch for all headers and made a pull request. The owner of the library improved it by adding a new value in MessageSummaryItems
.
Usage:
var messageSummaries = folder.Fetch(uids, MessageSummaryItems.Headers);
Note: Until a new release is done, you ll have to build your own from github master.
Upvotes: 3