Azkik
Azkik

Reputation: 85

Using MailKit, can I get the subject or sender email without downloading entire message in POP?

I have an email with yahoo business and MailKit works with POP. I want to download the message after finding a specific subject. Or could I use IMAP?

Upvotes: 2

Views: 3893

Answers (1)

jstedfast
jstedfast

Reputation: 38528

If the POP3 server supports the TOP extension, you can download just the message headers to first check the subject. To do that, you could do something like this:

if (client.Capabilities.HasFlag (Pop3Capabilities.Top)) {
    var headers = client.GetMessageHeaders (index);
    if (headers[HeaderId.Subject] == subject)
        message = client.GetMessage (index);
}

If your Yahoo account also supports IMAP, I would recommend using IMAP since IMAP allows you to query the server for messages with a given subject which is much more efficient than downloading the headers for every message to check if the subject matches the one you are looking for.

Upvotes: 1

Related Questions