You can optionally embed an image in the HTML body of the email. This allows you to include images without needing to host them in an external server.
We currently do not support sending attachments (including inline images) when using our batch endpoint.
1

Add the CID in the email HTML.

Use the prefix cid: to reference the ID in the src attribute of an image tag in the HTML body of the email.
  <img src="cid:logo-image">
2

Reference the CID in the attachment

Include the content_id parameter in the attachment object (e.g. content_id: "logo-image").
"attachments": [
    {
      "path": "https://resend.com/static/sample/logo.png",
      "filename": "logo.png",
      "content_id": "logo-image"
    }
  ]
The ID is an arbitrary string set by you, and must be less than 128 characters.

Implementation details

Both remote and local attachments are supported. All attachment requirements, options, and limitations apply to inline images as well. As with all our features, inline images are available across all our SDKs.

Remote image example

import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

await resend.emails.send({
  from: 'Acme <onboarding@resend.dev>',
  to: ['delivered@resend.dev'],
  subject: 'Thank you for contacting us',
  html: '<p>Here is our <img src="cid:logo-image"/> inline logo</p>',
  attachments: [
    {
      path: 'https://resend.com/static/sample/logo.png',
      filename: 'logo.png',
      contentId: 'logo-image',
    },
  ],
});

Local image example

import { Resend } from 'resend';
import fs from 'fs';

const resend = new Resend('re_xxxxxxxxx');

const filepath = `${__dirname}/static/logo.png`;
const attachment = fs.readFileSync(filepath).toString('base64');

await resend.emails.send({
  from: 'Acme <onboarding@resend.dev>',
  to: ['delivered@resend.dev'],
  subject: 'Thank you for contacting us',
  text: '<p>Here is our <img src="cid:logo-image"/> inline logo</p>',
  attachments: [
    {
      content: attachment,
      filename: 'logo.png',
      content_id: 'logo-image',
    },
  ],
});

Other considerations

Before adding inline images, consider the following.
  • As these images are sent as attachments, you need to encode your image as Base64 when sending the raw content via the API. There is no need to do this when passing the path of a remote image (the API handles this for you).
  • Inline images increase the size of the email.
  • Inline images may be rejected by some clients (especially webmail).
  • As with all attachments, we recommend adding a content_type (e.g. image/png) or filename (e.g. logo.png) parameter to the attachment object, as this often helps email clients render the attachment correctly.
All attachments (including inline images) do not currently display in the emails dashboard when previewing email HTML.