A was struggling with this same issue, so here is my solution overview - hope it helps!
How do you find Message-ID in the first place?
You can specify this when you send email via SendGrid 'send' API. Example POST call's JSON body could look like:
{"personalizations":[{"to":[{"email":"[email protected]","name":"John Doe"}],"subject":"Email title"}],"content": [{"type": "text/plain", "value": "Heya!"}],"from":{"email":"[email protected]","name":"myname"},"reply_to":{"email":"[email protected]","name":"myname"},"headers": {
"Message-ID": "<[email protected]>"}}
To be frank, I do not yet know the limitations for the "Message-ID" structure or formatting, but you can take a look at examples from other emails you receive e.g. in gmail "show original message" >> "Message-ID"
Now, when you want to send email as a reply to the previous one, your POST call's body could look like this:
{"personalizations":[{"to":[{"email":"[email protected]","name":"John Doe"}],"subject":"Email title"}],"content": [{"type": "text/plain", "value": "This is my reply!"}],"from":{"email":"[email protected]","name":"myname"},"reply_to":{"email":"[email protected]","name":"myname"},"headers": {
"Message-ID": "<[email protected]>",
"In-Reply-To": "<[email protected]>",
"References": "<[email protected]>"}}
Happy to hear more details/ideas around this!
P.S. A couple confusing things I ran into:
- SendGrid does not provide documentation around this!
- Message-ID is not the same as SendGrid's internal message ID, used for tracking email events and activity feed.
- Nor should you mix Message-ID with x-message-id, as I did, that you receive in API response's header when you send an email.
Best of luck!
subject
field – Distillation