My agentic slop goes here. Not intended for anyone else!
Query 3: Large Emails with Attachments from This Month#
Use Case Description#
Find 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.
Key JMAP Concepts Used#
- Size filtering: Using
minSizefilter condition - Attachment detection: Using
hasAttachmentfilter - Date range filtering: Using
afterfor current month - Complex filter conditions: Combining multiple AND conditions
- Body structure analysis: Inspecting attachment metadata
JMAP Request#
{
"using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
"methodCalls": [
[
"Email/query",
{
"accountId": "u12345678",
"filter": {
"operator": "AND",
"conditions": [
{
"hasAttachment": true
},
{
"minSize": 1048576
},
{
"after": "2024-08-01T00:00:00Z"
}
]
},
"sort": [
{
"property": "size",
"isAscending": false
}
],
"limit": 20
},
"q0"
],
[
"Email/get",
{
"accountId": "u12345678",
"#ids": {
"resultOf": "q0",
"name": "Email/query",
"path": "/ids"
},
"properties": [
"id", "threadId", "from", "subject", "receivedAt", "size",
"hasAttachment", "preview", "attachments", "bodyStructure"
]
},
"g0"
]
]
}
Expected Response Structure#
{
"methodResponses": [
[
"Email/query",
{
"accountId": "u12345678",
"queryState": "q1234567892",
"canCalculateChanges": true,
"position": 0,
"ids": ["Memail789", "Memail790", "Memail791"],
"total": 12,
"limit": 20
},
"q0"
],
[
"Email/get",
{
"accountId": "u12345678",
"state": "s9876543212",
"list": [
{
"id": "Memail789",
"threadId": "Tthread101",
"from": [{"email": "designer@agency.com", "name": "Sarah Designer"}],
"subject": "Final Logo Designs - Hi-Res Files",
"receivedAt": "2024-08-20T16:45:00Z",
"size": 5242880,
"hasAttachment": true,
"preview": "Hi! Here are the final logo designs in high resolution...",
"attachments": [
{
"id": "att1",
"blobId": "B789abc123",
"name": "company-logo-final.psd",
"mimeType": "application/octet-stream",
"size": 3145728,
"disposition": "attachment"
},
{
"id": "att2",
"blobId": "B789abc124",
"name": "company-logo-variants.zip",
"mimeType": "application/zip",
"size": 1572864,
"disposition": "attachment"
}
],
"bodyStructure": {
"id": "root",
"mimeType": "multipart/mixed",
"size": 5242880,
"headers": [...],
"subParts": [
{
"id": "text1",
"mimeType": "text/plain",
"size": 524288,
"headers": [...]
},
{
"id": "att1",
"mimeType": "application/octet-stream",
"size": 3145728,
"name": "company-logo-final.psd",
"disposition": "attachment",
"headers": [...]
},
{
"id": "att2",
"mimeType": "application/zip",
"size": 1572864,
"name": "company-logo-variants.zip",
"disposition": "attachment",
"headers": [...]
}
]
}
}
],
"notFound": []
},
"g0"
]
]
}
Explanation of Key Features#
Size-Based Filtering#
minSize: 1048576filters for emails larger than 1MB (1,048,576 bytes)- JMAP size values are in octets (bytes) of the raw RFC5322 message
- Combined with
hasAttachment: trueto focus on attachment-heavy emails
Date Range Patterns#
after: "2024-08-01T00:00:00Z"for current month filtering- Can be combined with
beforefor precise date ranges - UTC timestamps ensure consistent timezone handling
Attachment Analysis#
attachmentsproperty provides attachment metadata without downloading contentbodyStructureshows complete MIME tree structureblobIdallows selective download of specific attachments
Size-Based Sorting#
sortbysizedescending shows largest emails first- Useful for storage management and cleanup prioritization
- Alternative: sort by
receivedAtfor chronological order
Storage Management Use Cases#
This query pattern enables:
- Storage cleanup: Identify emails consuming most space
- Bandwidth optimization: Download large attachments selectively
- Archive decisions: Move old large emails to cold storage
- Quota management: Monitor attachment storage usage
- Mobile sync: Exclude large emails from mobile device sync
MIME Structure Navigation#
bodyStructureprovides hierarchical view of email partsdisposition: "attachment"distinguishes attachments from inline contentsubPartsarray allows recursive parsing of complex MIME structures- Part IDs enable targeted content retrieval via Email/get bodyValues