My agentic slop goes here. Not intended for anyone else!
1# Query 3: Large Emails with Attachments from This Month 2 3## Use Case Description 4Find emails from the current month that have attachments and are larger than 1MB. This helps identify storage-heavy emails for cleanup, archiving, or download management. 5 6## Key JMAP Concepts Used 7- **Size filtering**: Using `minSize` filter condition 8- **Attachment detection**: Using `hasAttachment` filter 9- **Date range filtering**: Using `after` for current month 10- **Complex filter conditions**: Combining multiple AND conditions 11- **Body structure analysis**: Inspecting attachment metadata 12 13## JMAP Request 14 15```json 16{ 17 "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"], 18 "methodCalls": [ 19 [ 20 "Email/query", 21 { 22 "accountId": "u12345678", 23 "filter": { 24 "operator": "AND", 25 "conditions": [ 26 { 27 "hasAttachment": true 28 }, 29 { 30 "minSize": 1048576 31 }, 32 { 33 "after": "2024-08-01T00:00:00Z" 34 } 35 ] 36 }, 37 "sort": [ 38 { 39 "property": "size", 40 "isAscending": false 41 } 42 ], 43 "limit": 20 44 }, 45 "q0" 46 ], 47 [ 48 "Email/get", 49 { 50 "accountId": "u12345678", 51 "#ids": { 52 "resultOf": "q0", 53 "name": "Email/query", 54 "path": "/ids" 55 }, 56 "properties": [ 57 "id", "threadId", "from", "subject", "receivedAt", "size", 58 "hasAttachment", "preview", "attachments", "bodyStructure" 59 ] 60 }, 61 "g0" 62 ] 63 ] 64} 65``` 66 67## Expected Response Structure 68 69```json 70{ 71 "methodResponses": [ 72 [ 73 "Email/query", 74 { 75 "accountId": "u12345678", 76 "queryState": "q1234567892", 77 "canCalculateChanges": true, 78 "position": 0, 79 "ids": ["Memail789", "Memail790", "Memail791"], 80 "total": 12, 81 "limit": 20 82 }, 83 "q0" 84 ], 85 [ 86 "Email/get", 87 { 88 "accountId": "u12345678", 89 "state": "s9876543212", 90 "list": [ 91 { 92 "id": "Memail789", 93 "threadId": "Tthread101", 94 "from": [{"email": "designer@agency.com", "name": "Sarah Designer"}], 95 "subject": "Final Logo Designs - Hi-Res Files", 96 "receivedAt": "2024-08-20T16:45:00Z", 97 "size": 5242880, 98 "hasAttachment": true, 99 "preview": "Hi! Here are the final logo designs in high resolution...", 100 "attachments": [ 101 { 102 "id": "att1", 103 "blobId": "B789abc123", 104 "name": "company-logo-final.psd", 105 "mimeType": "application/octet-stream", 106 "size": 3145728, 107 "disposition": "attachment" 108 }, 109 { 110 "id": "att2", 111 "blobId": "B789abc124", 112 "name": "company-logo-variants.zip", 113 "mimeType": "application/zip", 114 "size": 1572864, 115 "disposition": "attachment" 116 } 117 ], 118 "bodyStructure": { 119 "id": "root", 120 "mimeType": "multipart/mixed", 121 "size": 5242880, 122 "headers": [...], 123 "subParts": [ 124 { 125 "id": "text1", 126 "mimeType": "text/plain", 127 "size": 524288, 128 "headers": [...] 129 }, 130 { 131 "id": "att1", 132 "mimeType": "application/octet-stream", 133 "size": 3145728, 134 "name": "company-logo-final.psd", 135 "disposition": "attachment", 136 "headers": [...] 137 }, 138 { 139 "id": "att2", 140 "mimeType": "application/zip", 141 "size": 1572864, 142 "name": "company-logo-variants.zip", 143 "disposition": "attachment", 144 "headers": [...] 145 } 146 ] 147 } 148 } 149 ], 150 "notFound": [] 151 }, 152 "g0" 153 ] 154 ] 155} 156``` 157 158## Explanation of Key Features 159 160### Size-Based Filtering 161- `minSize: 1048576` filters for emails larger than 1MB (1,048,576 bytes) 162- JMAP size values are in octets (bytes) of the raw RFC5322 message 163- Combined with `hasAttachment: true` to focus on attachment-heavy emails 164 165### Date Range Patterns 166- `after: "2024-08-01T00:00:00Z"` for current month filtering 167- Can be combined with `before` for precise date ranges 168- UTC timestamps ensure consistent timezone handling 169 170### Attachment Analysis 171- `attachments` property provides attachment metadata without downloading content 172- `bodyStructure` shows complete MIME tree structure 173- `blobId` allows selective download of specific attachments 174 175### Size-Based Sorting 176- `sort` by `size` descending shows largest emails first 177- Useful for storage management and cleanup prioritization 178- Alternative: sort by `receivedAt` for chronological order 179 180### Storage Management Use Cases 181This query pattern enables: 182- **Storage cleanup**: Identify emails consuming most space 183- **Bandwidth optimization**: Download large attachments selectively 184- **Archive decisions**: Move old large emails to cold storage 185- **Quota management**: Monitor attachment storage usage 186- **Mobile sync**: Exclude large emails from mobile device sync 187 188### MIME Structure Navigation 189- `bodyStructure` provides hierarchical view of email parts 190- `disposition: "attachment"` distinguishes attachments from inline content 191- `subParts` array allows recursive parsing of complex MIME structures 192- Part IDs enable targeted content retrieval via Email/get bodyValues