GithubHelp home page GithubHelp logo

Comments (13)

jstedfast avatar jstedfast commented on August 18, 2024

What you're looking for is MessageSummaryItems.Flags (and IMessageSummary.Flags).

Then, what you want to do is check for the MessageFlags.Flagged value (which is aka "important").

from mimekit.

Sicos1977 avatar Sicos1977 commented on August 18, 2024

Thanks for the quick response

from mimekit.

Sicos1977 avatar Sicos1977 commented on August 18, 2024

For some reason I don't see the flagged value in the Flags. According to the log the only message in my inbox (that I did put there as important) seems to be flagged. But when I look into the IMessageSummary.Flags I only see [Seen | Deleted]. Flagged is never in the list.

This is the code I use to retrieve the messages:
using (var client = new ImapClient(new ProtocolLogger("d:\log.txt")))
{
client.Connect(Server, 993, true);
client.AuthenticationMechanisms.Remove("XOAUTH");
client.Authenticate(User, Password);
client.Inbox.Open(FolderAccess.ReadOnly);

                const MessageSummaryItems items =
                    MessageSummaryItems.UniqueId |
                    MessageSummaryItems.Flags |
                    MessageSummaryItems.Envelope | 
                    MessageSummaryItems.MessageSize;

                var result = client.Inbox.Count == 0 ? new IMessageSummary[0] : client.Inbox.Fetch(0, -1, items);
                client.Disconnect(true);
                return result;
            }

S: Z00000001 OK AUTHENTICATE completed.
C: Z00000002 CAPABILITY
S: * CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN IDLE NAMESPACE LITERAL+
S: Z00000002 OK CAPABILITY completed.
C: Z00000003 NAMESPACE
S: * NAMESPACE (("" "/")) NIL NIL
S: Z00000003 OK NAMESPACE completed.
C: Z00000004 LIST "" "INBOX"
S: * LIST (\Marked \HasNoChildren) "/" INBOX
S: Z00000004 OK LIST completed.
C: Z00000005 EXAMINE INBOX
S: * 1 EXISTS
S: * 0 RECENT
S: * FLAGS (\Seen \Answered \Flagged \Deleted \Draft $MDNSent)

from mimekit.

jstedfast avatar jstedfast commented on August 18, 2024

Do any of the messages have \Flagged in their flag list in the server response?

from mimekit.

Sicos1977 avatar Sicos1977 commented on August 18, 2024

I did put 2 E-mails in the inbox:

  • One with prio low flag set
  • One with prio high flag set

from mimekit.

jstedfast avatar jstedfast commented on August 18, 2024

You mean MailKit (MimeKit just parses messages, it doesn't do IMAP).

Anyway, I thought you were asking about something else (no IMAP client uses the message headers to determine importance, they all use the IMAP \Flagged flag).

But anyway, if you want the Importance, Priority, X-Priority, X-MSMail-Priority, etc headers, then what you need to do is download the message headers for each message and check them.

from mimekit.

jstedfast avatar jstedfast commented on August 18, 2024

I've just committed a patch to MailKit to allow fetching specific headers along with the summaries.

You can now do:

const MessageSummaryItems items =
                    MessageSummaryItems.UniqueId |
                    MessageSummaryItems.Flags |
                    MessageSummaryItems.Envelope | 
                    MessageSummaryItems.MessageSize;
HashSet<HeaderId> fields = new HashSet<HeaderId> ();

fields.Add (HeaderId.Importance);

var result = client.Inbox.Count == 0 ? new IMessageSummary[0] : client.Inbox.Fetch(0, -1, items, fields);

from mimekit.

Sicos1977 avatar Sicos1977 commented on August 18, 2024

Thanks for implementing, is this also in the nuget package or do I need to download the code from Git hub?

from mimekit.

jstedfast avatar jstedfast commented on August 18, 2024

I haven't released it as a NuGet package yet, but I can do that tonight or tomorrow morning (depending on when I get home tonight)

from mimekit.

Sicos1977 avatar Sicos1977 commented on August 18, 2024

Just another question... looking to your avatar on GitHub... are you a mountainbiker? If so then we share a second thing... like to code and like to mountainbike :-)

Also my apologies for my terrible English... not always used to talk a lot in English since Dutch is my native language :-)

from mimekit.

jstedfast avatar jstedfast commented on August 18, 2024

I actually am more into road biking (the photo of me is actually biking on the road through a park)

from mimekit.

Sicos1977 avatar Sicos1977 commented on August 18, 2024

I also checked your TNEF implementation.. while it looks a lot like the MAPI things I don't think it covers everything what I use. I see a lot of MAPI properties that are the same but there are also differences. One other thing is that a MSG file also uses named MAPI properties and those you have to get from the __nameid_version1.0 stream in a msg object. It took me some time to figure out how to map the named properties. The problem is that named properties not always have the same tags. One time the property can be value 8010 and the second time it can be 8040... etc... you have to look them up in the __nameid_version1.0 stream. The mappings are somewhat encrypted. You need to read the bits and bytes from the stream in a defined order and then swap the bytes because they are in little endian. It took me some time to figure that out.... see the MapiTagMapperClass.

    /// <summary>
    ///     The stream that contains all the MAPI properties
    /// </summary>
    public const string PropertiesStream = "__properties_version1.0";

    /// <summary>
    ///     Contains the streams needed to perform named property mapping
    /// </summary>
    public const string NameIdStorage = "__nameid_version1.0";

from mimekit.

jstedfast avatar jstedfast commented on August 18, 2024

interesting... thanks for the info. Doing a bit more reading, it looks like TNEF encapsulates only a subset of MAPI.

from mimekit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.