Send Email with Inline Embedded Image via Gmail API - n8n Workflow

Learn how to send professional emails with inline embedded images using custom MIME construction and an HTTP Request n8n node. This n8n workflow template provides advanced Gmail automation capabilities.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation specialists needing granular control over email formatting.
Users requiring reliable inline image embedding that bypasses standard Gmail attachment behavior.
Developers looking for advanced n8n templates for custom email reporting.
Anyone utilizing n8n to generate and distribute visual data or charts.

Overview

This advanced n8n workflow addresses a common challenge in email automation: embedding an image directly into the email body (inline) rather than just attaching it. While standard Gmail n8n nodes often default to attachments, this specific n8n workflow template leverages the raw power of the Gmail API via an HTTP Request n8n node. It fetches an image, converts it to base64 encoding, and then expertly constructs a multipart MIME message. This ensures your recipients see the image immediately displayed within the email content, making it a powerful and professional solution for automated reports or notifications generated by an n8n workflow. Using this powerful n8n workflow means you control the exact presentation of your emails.

How it Works

The process begins with the manual n8n trigger, labeled "When clicking 'Test workflow'". First, the "Message settings" n8n node defines the sender, recipient, subject, and the crucial HTML body which includes the placeholder . Next, the "Get image" n8n node fetches the desired binary image data from a specified external URL. The "Convert image to base64" n8n node then prepares this image for embedding by transforming the binary data into a base64 string, assigning it to a property called chart1. The "Compose message" n8n node uses extensive expressions to combine the email headers, the HTML body, and the base64 encoded image data into a complex raw MIME message structure, adhering to the multipart/related specification required for inline embedding. Finally, the "Send message" n8n node (an HTTP Request n8n node configured with Gmail OAuth) posts the final base64-encoded raw MIME message to the Gmail API's /messages/send endpoint, completing the execution of the n8n workflow.

Installation Guide

To install and utilize this high-level n8n workflow template:


  1. Import: Copy the provided JSON data and import it into your n8n instance via the 'Workflows' screen using the 'New' -> 'Import from JSON' option.

  2. Credentials: The "Send message" HTTP Request n8n node requires valid Gmail OAuth2 credentials. You must create and configure a set of Gmail OAuth credentials (ID '198' in the source JSON) within n8n and link them to this node.

  3. Update Settings: Navigate to the "Message settings" n8n node and update the from and to values with your actual sender and recipient email addresses.

  4. Image Source: If you wish to use a different image, update the URL in the "Get image" HTTP Request n8n node.

  5. Test: Click the "When clicking 'Test workflow'" n8n trigger node and click 'Test workflow' to verify successful execution and delivery.

Node Details

When clicking "Test workflow" (n8n trigger): This manual n8n trigger node is used strictly for development and testing. It initiates the n8n workflow process immediately upon clicking 'Test workflow'.
Message settings (Set n8n node): This n8n node defines the core parameters of the email. Key configuration includes defining the HTML body as

, establishing the link between the HTML and the embedded image data.
Get image (HTTP Request n8n node): Fetches the external image file as binary data from a specified URL. This binary data is essential for the next step of the n8n workflow.
Convert image to base64 (Extract From File n8n node): Converts the incoming binary image data into a base64 string, which is necessary for embedding the image within the MIME structure. It stores the result in a property named chart1.
Compose message (Set n8n node): This highly specialized n8n node generates the entire raw MIME payload. It uses complex string concatenation and template literals to structure the email headers, the HTML content, the image MIME block, and the base64 encoded image data ($json.chart1).
Send message (HTTP Request n8n node): This final n8n node sends the constructed raw MIME message to the Gmail API. It requires Gmail OAuth authentication and ensures the raw data is base64 encoded again before sending it in the API request body. This is the crucial step that executes the Gmail automation portion of the n8n workflow.

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by
David Roberts
David Roberts

Featured*