My agentic slop goes here. Not intended for anyone else!
1# Query 6: Recent Emails Sent to Company Domain 2 3## Use Case Description 4Find emails sent to colleagues within the company domain in the last 30 days. This demonstrates EmailSubmission queries, domain-based filtering, and tracking of outgoing communications. 5 6## Key JMAP Concepts Used 7- **EmailSubmission/query**: Tracking sent emails via submission records 8- **Domain filtering**: Using email address patterns to match company domain 9- **Sent mailbox discovery**: Finding sent items via mailbox role 10- **Date range filtering**: Recent activity within time window 11- **Submission status tracking**: Understanding email delivery states 12 13## JMAP Request 14 15```json 16{ 17 "using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"], 18 "methodCalls": [ 19 [ 20 "Mailbox/query", 21 { 22 "accountId": "u12345678", 23 "filter": { 24 "role": "sent" 25 } 26 }, 27 "mb0" 28 ], 29 [ 30 "EmailSubmission/query", 31 { 32 "accountId": "u12345678", 33 "filter": { 34 "operator": "AND", 35 "conditions": [ 36 { 37 "after": "2024-07-25T00:00:00Z" 38 }, 39 { 40 "operator": "OR", 41 "conditions": [ 42 { 43 "to": "*@mycompany.com" 44 }, 45 { 46 "cc": "*@mycompany.com" 47 }, 48 { 49 "bcc": "*@mycompany.com" 50 } 51 ] 52 } 53 ] 54 }, 55 "sort": [ 56 { 57 "property": "created", 58 "isAscending": false 59 } 60 ], 61 "limit": 25 62 }, 63 "sub0" 64 ], 65 [ 66 "EmailSubmission/get", 67 { 68 "accountId": "u12345678", 69 "#ids": { 70 "resultOf": "sub0", 71 "name": "EmailSubmission/query", 72 "path": "/ids" 73 }, 74 "properties": [ 75 "id", "emailId", "identityId", "envelope", "created", 76 "deliveryStatus", "dsnBlobIds", "mdnBlobIds" 77 ] 78 }, 79 "subg0" 80 ], 81 [ 82 "Email/get", 83 { 84 "accountId": "u12345678", 85 "#ids": { 86 "resultOf": "subg0", 87 "name": "EmailSubmission/get", 88 "path": "/list/*/emailId" 89 }, 90 "properties": [ 91 "id", "from", "to", "cc", "bcc", "subject", "sentAt", 92 "preview", "hasAttachment", "threadId" 93 ] 94 }, 95 "eg0" 96 ] 97 ] 98} 99``` 100 101## Expected Response Structure 102 103```json 104{ 105 "methodResponses": [ 106 [ 107 "Mailbox/query", 108 { 109 "accountId": "u12345678", 110 "queryState": "mq1234567894", 111 "canCalculateChanges": true, 112 "position": 0, 113 "ids": ["Msent"], 114 "total": 1, 115 "limit": null 116 }, 117 "mb0" 118 ], 119 [ 120 "EmailSubmission/query", 121 { 122 "accountId": "u12345678", 123 "queryState": "sq1234567894", 124 "canCalculateChanges": true, 125 "position": 0, 126 "ids": ["ES123", "ES124", "ES125"], 127 "total": 18, 128 "limit": 25 129 }, 130 "sub0" 131 ], 132 [ 133 "EmailSubmission/get", 134 { 135 "accountId": "u12345678", 136 "state": "s9876543215", 137 "list": [ 138 { 139 "id": "ES123", 140 "emailId": "Memail301", 141 "identityId": "I1", 142 "envelope": { 143 "mailFrom": "john.doe@mycompany.com", 144 "rcptTo": ["alice.smith@mycompany.com", "bob.jones@mycompany.com"] 145 }, 146 "created": "2024-08-23T14:30:00Z", 147 "deliveryStatus": { 148 "alice.smith@mycompany.com": "delivered", 149 "bob.jones@mycompany.com": "delivered" 150 }, 151 "dsnBlobIds": null, 152 "mdnBlobIds": null 153 }, 154 { 155 "id": "ES124", 156 "emailId": "Memail302", 157 "identityId": "I1", 158 "envelope": { 159 "mailFrom": "john.doe@mycompany.com", 160 "rcptTo": ["team@mycompany.com"] 161 }, 162 "created": "2024-08-22T16:15:00Z", 163 "deliveryStatus": { 164 "team@mycompany.com": "delivered" 165 }, 166 "dsnBlobIds": null, 167 "mdnBlobIds": null 168 } 169 ], 170 "notFound": [] 171 }, 172 "subg0" 173 ], 174 [ 175 "Email/get", 176 { 177 "accountId": "u12345678", 178 "state": "s9876543215", 179 "list": [ 180 { 181 "id": "Memail301", 182 "from": [{"email": "john.doe@mycompany.com", "name": "John Doe"}], 183 "to": [ 184 {"email": "alice.smith@mycompany.com", "name": "Alice Smith"}, 185 {"email": "bob.jones@mycompany.com", "name": "Bob Jones"} 186 ], 187 "cc": [], 188 "bcc": [], 189 "subject": "Weekly Team Sync - Action Items", 190 "sentAt": "2024-08-23T14:30:00Z", 191 "preview": "Hi team, Here's a summary of our action items from today's meeting...", 192 "hasAttachment": false, 193 "threadId": "Tthread501" 194 }, 195 { 196 "id": "Memail302", 197 "from": [{"email": "john.doe@mycompany.com", "name": "John Doe"}], 198 "to": [{"email": "team@mycompany.com", "name": "Engineering Team"}], 199 "cc": [], 200 "bcc": [], 201 "subject": "Code Review Guidelines Update", 202 "sentAt": "2024-08-22T16:15:00Z", 203 "preview": "Team, I've updated our code review guidelines based on recent feedback...", 204 "hasAttachment": false, 205 "threadId": "Tthread502" 206 } 207 ], 208 "notFound": [] 209 }, 210 "eg0" 211 ] 212 ] 213} 214``` 215 216## Explanation of Key Features 217 218### EmailSubmission vs Email Objects 219- **EmailSubmission**: Tracks the sending process and delivery status 220- **Email**: Contains message content and threading information 221- EmailSubmission links to Email via `emailId` property 222- Both objects provide different perspectives on sent messages 223 224### Domain-Based Filtering 225```json 226{ 227 "operator": "OR", 228 "conditions": [ 229 {"to": "*@mycompany.com"}, 230 {"cc": "*@mycompany.com"}, 231 {"bcc": "*@mycompany.com"} 232 ] 233} 234``` 235- Wildcard pattern `*@mycompany.com` matches any user at company domain 236- OR operator catches emails where any recipient field contains company addresses 237- Handles mixed internal/external recipient lists 238 239### Submission Envelope Information 240- `envelope.mailFrom`: SMTP sender address (may differ from From header) 241- `envelope.rcptTo`: Actual SMTP recipients (includes Bcc addresses) 242- `deliveryStatus`: Per-recipient delivery outcomes 243- `created`: When submission was initiated (vs email sentAt) 244 245### Delivery Status Tracking 246Possible `deliveryStatus` values: 247- `"queued"`: Accepted for delivery but not yet sent 248- `"delivered"`: Successfully delivered to recipient 249- `"failed"`: Permanent delivery failure 250- `"deferred"`: Temporary failure, retry scheduled 251- `"unknown"`: Status not available 252 253### Advanced Submission Queries 254 255**Failed Deliveries:** 256```json 257{ 258 "operator": "AND", 259 "conditions": [ 260 {"after": "2024-08-20T00:00:00Z"}, 261 {"deliveryStatus": "failed"} 262 ] 263} 264``` 265 266**Specific Identity Usage:** 267```json 268{ 269 "operator": "AND", 270 "conditions": [ 271 {"identityId": "I2"}, 272 {"after": "2024-08-01T00:00:00Z"} 273 ] 274} 275``` 276 277**High-Priority Submissions:** 278```json 279{ 280 "operator": "AND", 281 "conditions": [ 282 {"envelope/rcptTo": "*@vip-client.com"}, 283 {"deliveryStatus": "queued"} 284 ] 285} 286``` 287 288### Business Intelligence Use Cases 289This query pattern enables: 290- **Communication auditing**: Track internal vs external communications 291- **Collaboration analysis**: Identify team communication patterns 292- **Delivery monitoring**: Ensure critical messages reach colleagues 293- **Identity usage**: Understand which sending identities are used when 294- **Compliance reporting**: Document internal communication for compliance 295- **Network analysis**: Build organizational communication graphs 296 297### Integration with Email Analytics 298- Combine EmailSubmission delivery data with Email engagement metrics 299- Track which internal emails generate replies (thread analysis) 300- Monitor response times within organization 301- Identify communication bottlenecks or missed messages 302- Analyze meeting scheduling and follow-up patterns