KamoCRM

Handle IMAPInputStream in getMessage to prevent ClassCastException

FixEmailService
Shipped
26 ஏப்ரல், 2026 அன்று 4:19 AM UTC
Author
Kamo
Commit
5616354

JavaMail can return an IMAPInputStream instead of a decoded String from part.getContent() when message content has not been pre-fetched. The direct (String) casts in parseMultipart() threw ClassCastException for affected messages, causing fetchFullMessage to fail before mark-as-read was called, so emails never got marked read in classic mode. Add partContentAsString() helper that checks instanceof String first, then falls back to reading an InputStream with the part's charset. Add extractCharset() to parse charset from Content-Type header. Update parseMultipart() to use the helper for all text/* body parts. Also add InputStream branch to top-level getMessage() body parsing for single-part messages whose content arrives as a raw stream.

All changes

Like what you see shipping?

All of it arrives in your workspace on its own. Start on the free plan and read this page again in a month.

Start Free ForeverView Pricing