My agentic slop goes here. Not intended for anyone else!
1# Query 2: Apple Mail Orange Flagged Messages 2 3## Use Case Description 4Find the oldest message marked with Apple Mail's orange flag. Apple Mail uses a bit flag system where orange flags correspond to `$MailFlagBit1` keyword. This query demonstrates vendor-specific keyword handling and oldest-first sorting. 5 6## Key JMAP Concepts Used 7- **Apple Mail Extensions**: Using `$MailFlagBit1` keyword for orange flag 8- **Vendor-specific keywords**: Handling Apple Mail's color flag system 9- **Ascending sort**: Finding oldest messages first 10- **Single result limiting**: Using `limit: 1` to get just the oldest 11 12## JMAP Request 13 14```json 15{ 16 "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"], 17 "methodCalls": [ 18 [ 19 "Email/query", 20 { 21 "accountId": "u12345678", 22 "filter": { 23 "hasKeyword": "$MailFlagBit1" 24 }, 25 "sort": [ 26 { 27 "property": "receivedAt", 28 "isAscending": true 29 } 30 ], 31 "limit": 1 32 }, 33 "q0" 34 ], 35 [ 36 "Email/get", 37 { 38 "accountId": "u12345678", 39 "#ids": { 40 "resultOf": "q0", 41 "name": "Email/query", 42 "path": "/ids" 43 }, 44 "properties": [ 45 "id", "threadId", "mailboxIds", "keywords", "from", "subject", 46 "receivedAt", "sentAt", "preview", "textBody", "hasAttachment" 47 ] 48 }, 49 "g0" 50 ] 51 ] 52} 53``` 54 55## Expected Response Structure 56 57```json 58{ 59 "methodResponses": [ 60 [ 61 "Email/query", 62 { 63 "accountId": "u12345678", 64 "queryState": "q1234567891", 65 "canCalculateChanges": true, 66 "position": 0, 67 "ids": ["Memail456"], 68 "total": 1, 69 "limit": 1 70 }, 71 "q0" 72 ], 73 [ 74 "Email/get", 75 { 76 "accountId": "u12345678", 77 "state": "s9876543211", 78 "list": [ 79 { 80 "id": "Memail456", 81 "threadId": "Tthread789", 82 "mailboxIds": {"Mimportant": true, "Minbox": true}, 83 "keywords": { 84 "$MailFlagBit1": true, 85 "$flagged": true 86 }, 87 "from": [{"email": "boss@company.com", "name": "Jane Manager"}], 88 "subject": "Q4 Budget Review - Action Required", 89 "receivedAt": "2024-07-15T09:30:00Z", 90 "sentAt": "2024-07-15T09:28:00Z", 91 "preview": "Please review the attached Q4 budget proposal and provide feedback by Friday...", 92 "textBody": [ 93 { 94 "id": "text1", 95 "mimeType": "text/plain", 96 "size": 1542 97 } 98 ], 99 "hasAttachment": true 100 } 101 ], 102 "notFound": [] 103 }, 104 "g0" 105 ] 106 ] 107} 108``` 109 110## Explanation of Key Features 111 112### Apple Mail Color Flags 113Apple Mail uses a bit flag system for color categorization: 114- `$MailFlagBit0` - Red flag 115- `$MailFlagBit1` - Orange flag 116- `$MailFlagBit2` - Yellow flag 117- Combinations create other colors (e.g., red+yellow = green) 118 119### Vendor Keyword Extensions 120- JMAP supports custom keywords with `$` prefix for system/vendor keywords 121- Apple Mail specific keywords are preserved during sync 122- Other clients may display these as generic flags or ignore them 123 124### Oldest-First Search Pattern 125- `isAscending: true` on `receivedAt` sorts chronologically 126- `limit: 1` efficiently returns just the oldest match 127- Useful for finding forgotten important items or ancient flagged emails 128 129### Enhanced Property Set 130- `textBody` provides access to plain text content structure 131- Both `sentAt` and `receivedAt` show email timing 132- `keywords` object shows all applied flags and keywords 133 134### Business Logic Applications 135This pattern is useful for: 136- Finding long-overdue flagged action items 137- Auditing old important emails 138- Cleaning up stale flags and categories 139- Understanding email aging patterns