aboutsummaryrefslogtreecommitdiff
path: root/docs/workflows/find-email.org
blob: 0ef96158372c6784e70aa8fab5c30dbad7eb40ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#+TITLE: Find Email Workflow
#+AUTHOR: Craig Jennings & Claude
#+DATE: 2026-02-01

* Overview

This workflow searches local maildir to find and identify emails matching specific criteria. Uses mu (maildir indexer) for fast searching.

* Problem We're Solving

Craig needs to find specific emails - shipping confirmations, receipts, correspondence with specific people, or messages about specific topics. Manually browsing mail folders is slow and error-prone. mu provides powerful search capabilities over the local maildir.

* Exit Criteria

Search is complete when:
1. Matching emails are identified (or confirmed none exist)
2. Relevant information is reported (subject, date, from, message path)
3. Craig has what they need to proceed (info extracted, or path for further action)

* When to Use This Workflow

When Craig says:
- "find email about [topic]"
- "search for emails from [person]"
- "do I have an email about [subject]?"
- "look for [shipping/receipt/confirmation] email"
- Before extract-email workflow (to locate the target email)

* The Workflow
** Step 0: Context Hygiene

Before starting, write out the session context file and check with Craig whether we could compact the context. This might be a long process. If the context window collapses, we may forget important details. Writing out the session context prevents this data loss. 

** Step 1: Ensure Mail is Current (Optional)

If searching for recent emails, run sync-email workflow first:

#+begin_src bash
mbsync -a && mu index
#+end_src

Skip if Craig confirms mail is already synced.

** Step 2: Construct Search Query

mu supports powerful search syntax:

#+begin_src bash
# By sender
mu find from:jdslabs.com

# By subject
mu find subject:shipped

# By date range
mu find date:2w..now           # last 2 weeks
mu find date:2026-01-01..      # since Jan 1

# Combined queries
mu find from:fedex subject:tracking date:1w..now

# In specific folder
mu find maildir:/gmail/INBOX from:amazon

# Full text search
mu find "order confirmation"
#+end_src

** Step 3: Run Search

#+begin_src bash
mu find [query]
#+end_src

Default output shows: date, from, subject, path

For more detail:
#+begin_src bash
mu find --fields="d f s l" [query]  # date, from, subject, path
mu find --sortfield=date --reverse [query]  # newest first
#+end_src

** Step 4: Report Results

Report to Craig:
- Number of matches found
- Key details (date, from, subject) for relevant matches
- Message path if Craig needs to extract or read it

If no matches:
- Confirm the search was correct
- Suggest alternative search terms
- Consider if mail needs syncing first

* Search Query Reference

| Field    | Example                      | Notes                    |
|----------+------------------------------+--------------------------|
| from:    | from:amazon.com              | Sender address/domain    |
| to:      | to:c@cjennings.net           | Recipient                |
| subject: | subject:"order shipped"      | Subject line             |
| body:    | body:tracking                | Message body             |
| date:    | date:1w..now                 | Relative or absolute     |
| flag:    | flag:unread                  | unread, flagged, etc.    |
| maildir: | maildir:/gmail/INBOX         | Specific folder          |
| mime:    | mime:application/pdf         | Has attachment type      |

Combine with AND (space), OR (or), NOT (not):
#+begin_src bash
mu find from:amazon subject:shipped not subject:delayed
#+end_src

* Principles

- **Sync first if needed** - Searching stale mail misses recent messages
- **Start broad, narrow down** - Better to find too many than miss the target
- **Use date ranges** - Dramatically speeds up searches for recent mail
- **Report paths** - Message paths enable extract-email workflow

* Living Document

Update this workflow as we discover useful search patterns.