MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / BuildForwardHTMLBody

Function BuildForwardHTMLBody

internal/outbound/forward.go:233–260  ·  view source on GitHub ↗

BuildForwardHTMLBody composes the text/html body of a forward. The caller's HTML comment is emitted as-is (the API contract treats html_body as caller-controlled markup); the forwarded block is wrapped in a blockquote so mail clients render it visually as a quote.

(commentHTML string, ctx ForwardContext)

Source from the content-addressed store, hash-verified

231// html_body as caller-controlled markup); the forwarded block is wrapped
232// in a blockquote so mail clients render it visually as a quote.
233func BuildForwardHTMLBody(commentHTML string, ctx ForwardContext) string {
234 var buf strings.Builder
235 if c := strings.TrimSpace(commentHTML); c != "" {
236 buf.WriteString(c)
237 buf.WriteString("\r\n<br><br>\r\n")
238 }
239 buf.WriteString(`<div class="forwarded">`)
240 buf.WriteString("\r\n")
241 buf.WriteString("---------- Forwarded message ---------<br>\r\n")
242 writeHTMLHeaderLine(&buf, "From", ctx.From)
243 writeHTMLHeaderLine(&buf, "Date", ctx.Date)
244 writeHTMLHeaderLine(&buf, "Subject", ctx.Subject)
245 writeHTMLHeaderLine(&buf, "To", ctx.To)
246 writeHTMLHeaderLine(&buf, "Cc", ctx.Cc)
247 buf.WriteString("<br>\r\n")
248 if ctx.HTML != "" {
249 buf.WriteString(`<blockquote style="margin:0 0 0 0.8ex;border-left:1px solid #ccc;padding-left:1ex">`)
250 buf.WriteString("\r\n")
251 buf.WriteString(ctx.HTML)
252 buf.WriteString("\r\n</blockquote>")
253 } else if ctx.Text != "" {
254 buf.WriteString(`<blockquote style="margin:0 0 0 0.8ex;border-left:1px solid #ccc;padding-left:1ex"><pre>`)
255 buf.WriteString(htmlEscape(ctx.Text))
256 buf.WriteString("</pre></blockquote>")
257 }
258 buf.WriteString("\r\n</div>")
259 return buf.String()
260}
261
262func writeHeaderLine(buf *strings.Builder, name, value string) {
263 if value == "" {

Calls 3

writeHTMLHeaderLineFunction · 0.85
htmlEscapeFunction · 0.85
StringMethod · 0.45