Skip to content

Commit fe596fe

Browse files
committed
Add MESSAGE-ID article
1 parent 7c0a46a commit fe596fe

1 file changed

Lines changed: 158 additions & 0 deletions

File tree

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
layout: post
3+
title: "How to Find an Exact Gmail Thread with Codex or Claude"
4+
date: 2026-08-20 22:05:48
5+
categories: Web Development
6+
meta: "Use Gmail’s Message-ID to point Codex or Claude at one exact email and retrieve the complete conversation rather than a plausible result."
7+
faq:
8+
- question: "How do I point Codex or Claude at one exact Gmail email?"
9+
answer: "Copy the email’s complete Message-ID from Gmail’s Show original view, then ask the agent to find that email and retrieve its Gmail thread."
10+
- question: "Where can I find a Gmail email’s Message-ID?"
11+
answer: "Open the email in Gmail on a computer, select More next to Reply, then select Show original. Find Message-ID and copy its complete value, including everything on both sides of the @ sign."
12+
- question: "Is Message-ID the same as a Gmail thread ID?"
13+
answer: "No. Message-ID identifies one particular email. Gmail’s own threadId identifies the conversation that Gmail has grouped around that email."
14+
- question: "Does knowing a Message-ID give an AI access to an email?"
15+
answer: "No. The agent still needs an authorised Gmail connection to an account containing the email. A Message-ID improves lookup; it is not a password or proof of who sent the message."
16+
---
17+
18+
I was organising flights and accommodation around a [speaking
19+
engagement](/speaking/) and wanted an LLM (I have a virtual personal assistant
20+
in ChatGPT called _Luma_ who is trained on almost every facet of my working
21+
life) to pull the dates, times, and locations from the relevant Gmail
22+
conversation. It found an email about the correct event, but it wasn’t the
23+
specific email I had in mind. The answer _looked_ realistic while relying on the
24+
wrong source.
25+
26+
Subjects, senders, dates, and snippets are all useful ways to _search_
27+
a mailbox, but they’re poor ways to name _an_ exact email. It turns out, the
28+
solution was already inside the email itself: its
29+
[`Message-ID`](https://www.rfc-editor.org/rfc/rfc5322.html#section-3.6.4).
30+
31+
A complete `Message-ID` gives the agent a precise email to find. Once Gmail
32+
finds that message, the agent can use Gmail’s own `threadId` to open the
33+
conversation around it. I tested this successfully with both Codex and Claude’s
34+
Gmail integrations.
35+
36+
## How to Copy a Gmail Email’s `Message-ID`
37+
38+
In Gmail, on a computer:
39+
40+
1. Open the individual email you want the agent to use.
41+
2. Next to _Reply_, select _More_ (the three dots), then _Show original_.
42+
3. Find `Message-ID` and copy its complete value.
43+
44+
It should look something like this:
45+
46+
```text
47+
<20260820.204553.7f3a@example.com>
48+
```
49+
50+
Keep the whole thing, including everything before and after the `@`. I also
51+
leave the angle brackets intact so there’s no ambiguity about what I copied.
52+
Google actually documents the [_Show original_
53+
route](https://support.google.com/mail/answer/29436?hl=en) for viewing an
54+
email’s full header.
55+
56+
## Give This Prompt to Codex or Claude
57+
58+
Replace the invented `Message-ID` below with the one you copied:
59+
60+
```text
61+
Using the connected Gmail account, locate the exact email whose complete
62+
Message-ID header is <20260820.204553.7f3a@example.com>, then retrieve its
63+
complete Gmail thread, including replies. Tell me the subject, sender, and date,
64+
then summarise the conversation. Do not reply, forward, label, archive, or
65+
delete anything.
66+
```
67+
68+
That last sentence keeps lookup and action separate. Once the agent has found
69+
the right conversation, ask whatever you actually wanted to know about it.
70+
71+
{% include promo.html %}
72+
73+
## Why `Message-ID` Works Better Than a Subject
74+
75+
While a subject _describes_ an email, it doesn’t identify it. Replies normally
76+
reuse the same subject, unrelated conversations can share one, and a frequent
77+
sender may account for hundreds of messages. And although a Gmail browser URL
78+
can contain details that make sense to the interface, they aren’t useful to an
79+
integration.
80+
81+
`Message-ID` was designed to give one particular version of one particular
82+
message a machine-readable identity. Gmail even documents an
83+
[`rfc822msgid:` search
84+
operator](https://support.google.com/mail/answer/7190?hl=en-GB) specifically
85+
for finding email with a given message-ID header.
86+
87+
The important sequence is:
88+
89+
0. Message-ID.
90+
1. exact email,
91+
2. Gmail threadId,
92+
3. complete Gmail conversation.
93+
94+
The `Message-ID` identifies the email, **not the thread**. Gmail’s API returns
95+
a separate `threadId` for the conversation containing that message. Its
96+
[`threads` resource](https://developers.google.com/workspace/gmail/api/guides/threads)
97+
then provides the messages Gmail has grouped into that conversation, in order.
98+
99+
The RFC gives us a portable way to refer to an email, and Gmail gives us its own
100+
view of the surrounding conversation. There is no universal email-thread
101+
identifier, and another provider may group the same messages differently.
102+
103+
## A Brief History of `Message-ID`
104+
105+
The field has been with us for more than four decades. [RFC
106+
822](https://www.rfc-editor.org/rfc/rfc822.html#section-4.6.1) defined
107+
`Message-ID` for Internet text messages in 1982. [RFC
108+
2822](https://www.rfc-editor.org/rfc/rfc2822.html) replaced it in 2001, then
109+
[RFC 5322](https://www.rfc-editor.org/rfc/rfc5322.html) replaced that in 2008
110+
and remains the current Internet Message Format specification.
111+
112+
For the other RFC-curious people in the room, RFC 882 really does exist, but
113+
it’s a 1983 document about [domain-name concepts and
114+
facilities](https://www.rfc-editor.org/rfc/rfc882.html).
115+
116+
There’s also a lovely bit of standards language hiding here. RFC 5322 says
117+
every message **SHOULD** have a `Message-ID`; in other words, you may still
118+
encounter an old, broken, or unusual email without one. When a system does
119+
generate an ID, however, that identifier **MUST** be globally unique, and the
120+
system generating it must guarantee that uniqueness.
121+
122+
There’s no central registry handing these out. A sending system typically
123+
combines a locally unique value with a domain it controls, which explains why
124+
they often look vaguely like an email address while being quite meaningless to
125+
a human:
126+
127+
```text
128+
Message-ID: <20260820.204553.7f3a@example.com>
129+
```
130+
131+
The angle brackets are part of the header’s syntax. The useful identity is the
132+
complete value inside them; copying everything avoids any accidental damage.
133+
134+
## What `Message-ID` Can’t Promise
135+
136+
This method makes the target more precise, but it doesn’t make email infallible.
137+
A mailbox may contain several stored copies of the same message carrying the
138+
same ID, and broken software can create malformed or duplicate IDs. Gmail may
139+
also return a whole conversation because one email inside it matched the
140+
search — which, for our purposes, is actually exactly what we want.
141+
142+
A forwarded email will also normally be a new message with a new `Message-ID`.
143+
If someone attaches the original email, the attached copy can retain its old
144+
ID while the outer forwarding message has another. It’s safer to copy the ID
145+
from the exact email you want to discuss than to assume one ID follows every
146+
future version around.
147+
148+
Finally, a `Message-ID` is neither a password nor proof of authorship. The
149+
agent still needs permission to read the connected Gmail account, and the
150+
message still needs to exist there. The identifier helps it find the right
151+
thing inside data it can already access; it grants no access of its own.
152+
153+
{% include cross-sell.html %}
154+
155+
When the exact source matters, preserve the complete `Message-ID`, ask the agent
156+
to retrieve Gmail’s returned thread, then ask what you need to know. It takes
157+
a little more effort than asking ChatGPT to look up a subject line, but it gives
158+
the it one exact email to work from. Much safer!

0 commit comments

Comments
 (0)