Lesson 23medium15 min
Formatting and Sending Email Reports via Gmail
Construct clean HTML email templates from agent output and deliver them via Gmail.
Learning Objectives
- Connect the output of the AI Agent node to a downstream Gmail node
- Format markdown agent text into clean HTML email formatting
- Configure Gmail OAuth2 credentials and send parameters
Formatting and Sending Email Reports via Gmail
Once the agent completes its ReAct loop, it emits the final synthesized text. We now route that output to Gmail as an HTML email digest.
Connecting the Gmail Node
- Add a Gmail node connected to the output of the AI Agent node.
- Resource: Message
- Operation: Send
- To:
your-email@company.com - Subject:
={{ 'Executive Daily Briefing: ' + $now.toFormat('EEE, MMM dd') }} - Email Type: HTML
Advertisement
Markdown to HTML Conversion
The agent outputs markdown. To render it cleanly in email clients, pass it through an intermediate Markdown node or convert basic headers:
html
<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #1a1a1a; max-width: 600px; margin: 0 auto;">
<div style="background-color: #2563eb; color: white; padding: 20px; border-radius: 8px 8px 0 0;">
<h1 style="margin: 0; font-size: 20px;">Daily Executive Intelligence</h1>
<p style="margin: 5px 0 0 0; opacity: 0.9; font-size: 14px;">{{ $now.toFormat('FFFF') }}</p>
</div>
<div style="padding: 24px; border: 1px solid #e5e7eb; border-top: none; border-radius: 0 0 8px 8px;">
{{ $json.output }}
</div>
</div>