fix(msg): preserve To, Cc, and Bcc recipient roles

AF
9h ago
+122-8

Summary

Outlook's recipient table contains To, Cc, and Bcc rows. partition_msg() currently puts every row into metadata.sent_to and obtains the separate Cc/Bcc fields only from transport headers. This misclassifies copied recipients, and loses their roles when the headers are absent even though the MSG recipient table still records them.

Read PidTagRecipientType from each recipient and preserve its role. Transport Cc/Bcc headers remain preferred when present, retaining display names and quoted commas. When they are absent, the corresponding recipient-table rows supply the addresses. Recipient records lacking a type retain the previous primary-recipient fallback. The MAPI_SUBMITTED flag is masked off when determining the role, as described by the Microsoft recipient mapping specification.

The repository's fake-email-with-cc-and-bcc.msg now produces:

  • sent_to: john-ctr@unstructured.io
  • cc_recipient: steve@unstructured.io
  • bcc_recipient: hello@unstructured.io

Previously, all three addresses appeared in sent_to.

Validation

  • Five new cases use the existing real MSG fixture, including a public partition_msg() call, absent transport headers, the submitted flag, no primary recipient, and missing recipient-type compatibility. On unchanged main, 4 fail and 1 passes; all pass with the fix.
  • MSG suites excluding the image/PDF attachment integration case: 71 passed, 1 deselected. That existing integration case requires the optional image/PDF inference dependencies and fails unchanged in this environment because they are not installed.
  • Full-repository Ruff lint and formatting pass.
  • git diff --check passes.
  • Full make test has not been run.

Release note

sent_to now identifies primary MSG recipients. To collect all recipient roles, combine sent_to, cc_recipient, and bcc_recipient. Files with no recipient-type property retain their previous fallback behavior.

Validation follow-up

  • The formal repository-wide make check command passes in the shared validation worktree containing both #4840 and #4841. This checks their combined tree; it is not a claim that the two remote heads were separately tested.
  • The current CI workflow run is completed with action_required and has started zero jobs. It supplies no CI test result yet. The full make test and coverage gates remain unverified and await hosted CI approval.

Checklist

  • The PR title is a user-facing release-note entry with a conventional commit prefix.
  • Apply the bug category label; a maintainer may need to apply it.
  • The corrected metadata behavior is described above.