emlx flags?

Is there any documentation on what the flags field in Mail.app .emlx files is?

Mail.app in 10.4 stores each message in its own file. The first line has an ASCII integer on it, the length in bytes of the message; then comes the message; then an XML "plist" blob with a few key/value pairs like "sender" and "subject". One of those properties is "flags", holding an integer, presumably bits indicating "unread", "replied", etc. But there are a lot of bits set in there -- some otherwise-uncomplicated messages seem to make use of up to 30 bits. What are they?

Update: Please, people, I asked a very straightfoward question. I'm not interested in your guesses. I can guess too. I'm looking for facts. I can also reverse-engineer at least some of it, if I have to. But I'd rather not, if it's actually documented somewhere. Which is why I asked. If you don't know, put your hand down.

Update: An anonymous benefactor has the goods:

    0read1 << 0
    1deleted1 << 1
    2answered1 << 2
    3encrypted1 << 3
    4flagged1 << 4
    5recent1 << 5
    6draft1 << 6
    7initial (no longer used)1 << 7
    8forwarded1 << 8
    9redirected1 << 9
    10-15  attachment count3F << 10 (6 bits)
    16-22  priority level7F << 16 (7 bits)
    23signed1 << 23
    24is junk1 << 24
    25is not junk1 << 25
    26-28  font size delta7 << 26 (3 bits)
    29junk mail level recorded     1 << 29
    30highlight text in toc1 << 30

Thank you Mask Man!

Update, 7 Aug 2005: I've posted my Perl code to parse these files: emlx.pl. Using this code you can, e.g., ssh in to your mac and see what messages Mail.app has downloaded while you were away.

Tags: , , , ,
Current Music: Coil -- Hellraiser ♬

24 Responses:

  1. legolas says:

    Are 'importance' high, low and neither an outlook extension to email or are they standard? If standard, that could be 2 of the bits.

  2. dr_gluck_ says:

    probably flag for follow-up combined with date/time follow-up is due eats up some of those bits. MS has color-enabled flags too -not sure if Mac cares about that though --maybe something similar.

  3. Hooks for Spotlight, looks like. Read the man pages for mdfind and mdls.

  4. duskwuff says:

    Okay, straightforward answer: No, there is no documentation.

    • strspn says:

      In order to exaust your administrative remedies, i.e., before faxing a photocopy of your anatomy polite letter to Steve Jobs (408-996-0275), you must ask here.

  5. emexgee says:

    i've been watching this conversion to mac-dom with some bemusement: surely the point of using a mac is that "it just works" and that you're supposed to spend more time doing things rather than trying to recompile the kernel & hack your applications so that you can do things...? and if that isn't what you actually get from using a mac (and my observation is that you're not getting that) then what's the point?

    some people are not happy unless they're hacking with something. admit this and be at peace.

    • jwz says:

      Well, the reason I'm looking at these flags at all is because I gave up on trying to install an IMAP server on my Linux machine, which leaves me with no easy way to read my mail when I'm not sitting in front of my Mac. (This is not a huge problem, but sometimes it would be nice.)

      So I thought, if I could just hack up a little script to dump any "unread" messages in my few inbox-ish folders to stdout, that would probably be just about good enough. (Certainly better than running "more" on the /var/spool/mail file on the server, since the spam and mailing lists would be omitted.)

      And for the record, I am positively giddy with how much of an improvement MacOS is over Linux. It's the bee's knees, as the kids say.

      • duskwuff says:

        Hmm. You could probably do some sort of cleverness with Applescript if you can be certain that you'll be logged into the console.

        Here's a first stab at it.

        osascript <<EOF
        on run argv
        set l to {}
        tell application "Mail"
        repeat with acct in every account
        set l to l & (subject of messages of \
        (mailboxes of acct whose name is "Inbox") \
        whose was read is false)
        end repeat
        end tell
        set r to ""
        repeat with i in l
        set r to r & i & "\n"
        end repeat
        return r
        end run
      • kfringe says:


        Giddy? Oh dear. That can't be a good sign.

    • duskwuff says:

      Just to be contrary, I'll note that you can compile and use your own Mach kernel if you really want to. It's just not necessary very often.

  6. larryklug says:

    Lenny Bruce rocks!

  7. baldnate says:

    Wait... a message can be junk and not junk? Reminds me of the tea and no tea in the old Hitchiker's Guide game...

    • jwz says:

      Well, there are 4 states: explicitly junk, explicitly not junk, implicitly junk, implicitly not junk. So you need two bits for that. It's unclear how exactly those two bits are used in flags, though.

  8. kensey says:

    10-15  	attachment count     3F < < 10 (6 bits)
    16-22 priority level 7F < < 16 (7 bits)

    How many attachments in a single message and priority levels do they anticipate ever existing, anyway?