0

I use mailkit library to read imap mails. I want to get mail with it's size. In Pop3 I can read mail size with;

clientPop.GetMessageSize("messageId");

In Imap,how can I do that?

fena coder
  • 217
  • 4
  • 17

1 Answers1

4

The way to get message metadata in IMAP is to use the Fetch() method on the folder. If you want to get the size of each message, you could do:

foreach (var summary in inbox.Fetch (0, -1, MessageSummaryItems.Size)) {
    Console.WriteLine ("The size of message {0} is {1}", summary.Index, summary.Size.Value);
}
jstedfast
  • 35,744
  • 5
  • 97
  • 110
  • Is it possible to get the mail size via the MimeMessage? I'm getting the mails via `inbox.GetMessage(uid)` – rogaa Jul 17 '20 at 09:49
  • 1
    You could write it to a `MimeKit.IO.MeasuringStream` and see what the `Length` is after you do. – jstedfast Jul 17 '20 at 12:43