简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM