Skip to content

feat: Add mail attachment and threading examples - #790

Open
svkaizoku wants to merge 4 commits into
sendgrid:mainfrom
svkaizoku:feat/add-attachments-example
Open

svkaizoku wants to merge 4 commits into
sendgrid:mainfrom
svkaizoku:feat/add-attachments-example

Conversation

@svkaizoku

Copy link
Copy Markdown

Adds Java examples for sending attachments, replying inside an existing email thread, and keeping same-subject emails in separate Gmail conversations. Also adds a use-case guide explaining which SendGrid ID threads a reply.

Changes

  • FileAttachmentExample: sends a regular file attachment.
  • InlineFileAttachmentExample: embeds an image with a Content-ID and references it from the HTML.
  • ThreadingExample: replies inside an existing thread using the smtp-id from the delivered webhook event, not the X-Message-Id returned by the send API.
  • PreventThreadingExample: sends three same-subject emails, each with a unique X-Entity-Ref-ID header, so Gmail keeps them in separate conversations.
  • use-cases/threaded-replies.md: explains the two IDs, how to match a webhook event to a send, how to check the headers in Gmail, and how to view webhook events.

Testing

The new classes are examples, so no library tests changed. Every example was run against the live SendGrid API, and the no-threading example was confirmed in Gmail as three separate conversations.

Fixes #

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

svkaizoku and others added 4 commits October 21, 2026 12:21
Add Java examples for sending attachments (regular and inline/CID) and for
replies and no-thread sends:

- FileAttachmentExample and InlineFileAttachmentExample show a regular
  attachment and an inline image referenced by Content-ID.
- ThreadingExample replies inside an existing thread using the smtp-id from
  the delivered webhook event.
- PreventThreadingExample keeps same-subject emails in separate Gmail
  conversations with a unique X-Entity-Ref-ID header.

Add use-cases/threaded-replies.md explaining why the smtp-id, not the
X-Message-Id returned by the send API, is the value that threads a reply,
and how to verify the result in Gmail.
Shrink the embedded image from 96x64 to 1x1 so the examples carry a few
dozen bytes of base64 instead of a full logo.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Replace the text block with string concatenation. Text blocks need Java 15,
and the library supports Java 8 and 11.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
A reply should use the original subject with "Re: " in front, so Gmail
groups it with the original message.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant