Send script — the mail DSL
The C# script DSL the Email page runs on the kernel for Send and Save as Outlook draft, and for the Preflight that runs before either: Mail.From(record).WithAttachment(a => a.FromNode(path).AsPdf(name)).AsUser(you).ApprovedBy(...).Send(), .SaveAsDraft() or .Preflight(). Preflight loads the mail runtime (Microsoft Graph, Kiota, Azure.Core, Markdig) by building a client it never uses, reads the record and every linked attachment, and mints the user's delegated token — and sends, exports and writes nothing. Send and Save as Outlook draft read the record, export every attachment to PDF through the platform's export activity, obtain the user's delegated Graph credential, build ONE message in the user's own mailbox with To, Cc, subject, the body rendered from markdown and the PDFs, then send it and stamp the record — or leave it in Outlook's Drafts and stamp the link — and verify the stamp by read-back. Every Graph type lives in MailRuntime and GraphMail only, so a kernel that cannot load Graph fails with a named [mail-runtime-unavailable] error before anything is exported. The page prepends this text to the plan it composes and writes the whole as {message}/Script or {message}/Preflight; not executable on its own.
- Code: // Essentials/Email — the DSL behind Send and Save as Outlook draft, and the Preflight that runs // before either. The message page prepends THIS text to the plan it composes from the record // (Mail.From(...).WithAttachment(...).AsUser(...).Send() | .SaveAsDraft() | .Preflight()), writes the // whole thing as {message}/Script (or {message}/Preflight) and runs it on the kernel as the person // who clicked. Not executable on its own: it declares the DSL and no plan. // // 🚨 Every Microsoft Graph type is touched ONLY inside MailRuntime and GraphMail. A method whose body // names a Graph type is JIT-compiled as a whole, so if the kernel cannot load Microsoft.Graph the // failure happens on ENTERING that method — before any line of it runs, with no message of ours. // Keeping Graph out of MailPlan is what lets Preflight() and Run() catch that failure and name it // with MailRuntime.Marker. using System; using System.Collections.Generic; using System.Linq; using System.Reactive.Linq; using System.Runtime.CompilerServices; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using MeshWeaver.Data; using MeshWeaver.Markdown.Export.Configuration; using MeshWeaver.Markdown.Export.Messaging; using MeshWeaver.Mesh; using MeshWeaver.Mesh.Services; using MeshWeaver.Messaging; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Graph; using Microsoft.Graph.Models; sealed class StaticToken(string token) : Azure.Core.TokenCredential { public override Azure.Core.AccessToken GetToken(Azure.Core.TokenRequestContext ctx, CancellationToken ct) => new(token, DateTimeOffset.UtcNow.AddMinutes(30)); public override ValueTask<Azure.Core.AccessToken> GetTokenAsync(Azure.Core.TokenRequestContext ctx, CancellationToken ct) => new(GetToken(ctx, ct)); } /// <summary> /// Proves the kernel can LOAD what delivery binds at run time — Microsoft.Graph…
- Is executable: no