Skip to content

[System Application] Add Message Headers blob and AddHeader/SetHeader/TryGetHeader on Email Message#8289

Draft
mynjj wants to merge 2 commits into
mainfrom
features/email-message-headers
Draft

[System Application] Add Message Headers blob and AddHeader/SetHeader/TryGetHeader on Email Message#8289
mynjj wants to merge 2 commits into
mainfrom
features/email-message-headers

Conversation

@mynjj
Copy link
Copy Markdown
Contributor

@mynjj mynjj commented May 23, 2026

Summary

  • Adds an additive internal "Message Headers" Blob field to Email Message (table 8900).
  • Exposes a name/value header surface on the public Email Message codeunit (8904):
    • AddHeader(HeaderName: Text; HeaderValue: Text) — appends; repeated names join with #10.
    • SetHeader(HeaderName: Text; HeaderValue: Text) — replaces any existing value.
    • TryGetHeader(HeaderName: Text; var Value: Text): Boolean — case-insensitive lookup.
  • All convention (trim + lowercase header names, repeated-value join with #10) is encapsulated in Email Message Impl. so callers don't need to know the storage shape.

No Email Connector interface version bump and no upgrade codeunit — a connector signals "I supply headers" by populating the blob. Empty == "headers not supplied".

The first commit lands the storage + an initial SetHeaders(JsonObject) shape; the second swaps that to the AddHeader/SetHeader/TryGetHeader primitives so the convention stays inside the module. Squashable into one commit before merge if preferred.

Motivated by the Payables Agent work that needs Graph's internetMessageHeaders (Authentication-Results, X-MS-Exchange-Organization-AuthAs, …) reachable from downstream consumers without re-hitting Graph. The matching uptake in the Outlook REST API connector is in a sibling NAV PR.

Test plan

  • EmailMessageHeadersTest (codeunit 134707) — four tests covering case-insensitive round-trip, missing-headers lookup, repeated-header #10 join, and SetHeader replace semantics.
  • Existing Email test suite green (no regressions on the surrounding Email Message API).

🤖 Generated with Claude Code

Joshua Martínez Pineda and others added 2 commits May 22, 2026 13:01
Connectors that retrieve RFC822-style headers (e.g. the Outlook REST API
connector reading internetMessageHeaders from Graph) can now persist them
as JSON on the Email Message payload via two new methods on the Email
Message codeunit:

    procedure SetHeaders(HeadersJson: JsonObject)
    procedure TryGetHeader(HeaderName: Text; var Value: Text): Boolean

Storage is a new internal Blob field on table 8900. Header names are
expected lowercased; lookups are case-insensitive (key trimmed and
lowercased before comparison). Multi-value headers are concatenated with
#10 by convention. Empty input clears the blob.

This is purely additive -- no Email Connector interface version bump
(connectors signal headers availability by populating the blob, not by
implementing a new interface), no upgrade codeunit. Downstream consumers
(PA / e-doc connectors) read this to classify mail without re-hitting
the provider.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tHeader primitives

Encapsulate the storage convention (lowercase keys, repeated headers
joined with #10) inside the Email Message codeunit rather than asking
each caller to pre-normalize a JsonObject. Public surface is now:

    procedure AddHeader(HeaderName: Text; HeaderValue: Text)
    procedure SetHeader(HeaderName: Text; HeaderValue: Text)
    procedure TryGetHeader(HeaderName: Text; var Value: Text): Boolean

AddHeader appends -- if a value already exists for that name it is
joined with the new value via #10, preserving the order in which
repeated headers like Received arrive. SetHeader replaces. Both
normalize the name (trim + lowercase) before storing; lookups apply
the same normalization, so callers don't have to.

The internal Blob field on Email Message is unchanged. Storage is
still JSON with lowercase keys, just no longer constructed by the
caller.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant