---
title: "Embed Images using CID"
slug: embed-images-using-cid
description: "Learn how to inline image attachments in your emails."
created_at: "2025-08-14"
updated_at: "2025-08-14"
image: https://cdn.resend.com/posts/embed-images-using-cid.jpg
humans: ["alexandre-cisneiros"]
---

Today, we're announcing support for inline image attachments using `CID` (or Content-ID).

Inlining an image embeds the image itself in the email (instead of hosting it somewhere else) and shows it inside the email body instead of an attachment.

<img
  src="https://cdn.resend.com/posts/embed-images-using-cid-1.jpg"
  alt="Tax ID"
  className="extraWidth"
/>

## How to embed images

Embedding images requires two steps:

### 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.

```html
<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"`).

```bash
"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.

## How it works

As with all our features, inline images are available across all our SDKs. [All attachment requirements, options, and limitations](/docs/dashboard/emails/attachments) apply to inline images as well.

Both remote and local attachments are supported, but here is an example of inlining remote images.

<CodeTabs codeHeight={320}>

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

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

```python
attachment: resend.RemoteAttachment = {
  "path": "https://resend.com/static/sample/logo.png",
  "filename": "logo.png",
  --highlight-start
  "content_id": "logo-image",
  --highlight-end
}

params: resend.Emails.SendParams = {
  "from": "Acme <onboarding@resend.dev>",
  "to": ["delivered@resend.dev"],
  "subject": "Thank you for contacting us",
  --highlight-start
  "html": "<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>",
  --highlight-end
  "attachments": [attachment],
}

resend.Emails.send(params)
```

```ruby
params = {
  "from": "Acme <onboarding@resend.dev>",
  "to": ["delivered@resend.dev"],
  "subject": "Thank you for contacting us",
  --highlight-start
  "html": "<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>",
  --highlight-end
  "attachments": [
    {
      "path": "https://resend.com/static/sample/logo.png",
      "filename": "logo.png",
      --highlight-start
      "content_id": "logo-image",
      --highlight-end
    }
  ]
}

Resend::Emails.send(params)
```

```go
func main() {
  ctx := context.TODO()
  client := resend.NewClient("re_xxxxxxxxx")

  attachment := &resend.Attachment{
    Path:  "https://resend.com/static/sample/logo.png",
    Filename: "logo.png",
    --highlight-start
    ContentId: "logo-image",
    --highlight-end
  }

  params := &resend.SendEmailRequest{
      From: "Acme <onboarding@resend.dev>",
      To: []string{"delivered@resend.dev"},
      Subject: "Thank you for contacting us",
      --highlight-start
      Html: "<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>",
      --highlight-end
      Attachments: []*resend.Attachment{attachment},
  }

  sent, err := client.Emails.SendWithContext(ctx, params)

  if err != nil {
    panic(err)
  }
  fmt.Println(sent.Id)
}
```

```rust
#[tokio::main]
async fn main() -> Result<()> {
  let resend = Resend::new("re_xxxxxxxxx");

  let from = "Acme <onboarding@resend.dev>";
  let to = ["delivered@resend.dev"];
  let subject = "Thank you for contacting us";

  let path = "https://resend.com/static/sample/logo.png";
  let filename = "logo.png";
  --highlight-start
  let content_id = "logo-image";
  --highlight-end

  let email = CreateEmailBaseOptions::new(from, to, subject)
  --highlight-start
    .with_html("<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>")
  --highlight-end
    .with_attachment(Attachment::from_path(path).with_filename(filename).with_content_id(content_id));

  let _email = resend.emails.send(email).await?;

  Ok(())
}
```

```java
public class Main {
    public static void main(String[] args) {
        Resend resend = new Resend("re_xxxxxxxxx");

        Attachment att = Attachment.builder()
                .path("https://resend.com/static/sample/logo.png")
                .fileName("logo.png")
                --highlight-start
                .ContentId("logo-image")
                --highlight-end
                .build();

        CreateEmailOptions params = CreateEmailOptions.builder()
                .from("Acme <onboarding@resend.dev>")
                .to("delivered@resend.dev")
                .subject("Thank you for contacting us")
                --highlight-start
                .html("<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>")
                --highlight-end
                .attachments(att)
                .build();

        CreateEmailResponse data = resend.emails().send(params);
    }
}
```

```dotnet
var message = new EmailMessage()
{
    From = "Acme <onboarding@resend.dev>",
    To = "delivered@resend.dev",
    Subject = "Thank you for contacting us",
    --highlight-start
    HtmlBody = "<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>",
    --highlight-end
};

message.Attachments = new List<EmailAttachment>();
message.Attachments.Add( new EmailAttachment() {
  Filename = "logo.png",
  Path = "https://resend.com/static/sample/logo.png",
  --highlight-start
  ContentId = "logo-image",
  --highlight-end
} );

var resp = await resend.EmailSendAsync( message );
Console.WriteLine( "Email Id={0}", resp.Content );
```

```curl
curl -X POST 'https://api.resend.com/emails' \
     -H 'Authorization: Bearer re_xxxxxxxxx' \
     -H 'Content-Type: application/json' \
     -d $'{
  "from": "Acme <onboarding@resend.dev>",
  "to": ["delivered@resend.dev"],
  "subject": "Thank you for contacting us",
  --highlight-start
  "html": "<p>Here is our <img src=\"cid:logo-image\"/> inline logo</p>",
  --highlight-end
  "attachments": [
    {
      "path": "https://resend.com/static/sample/logo.png",
      "filename": "logo.png",
      --highlight-start
      "content_id": "logo-image"
      --highlight-end
    }
  ]
}'
```
</CodeTabs>

## 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.

For more information on how to use inline images, check out our [documentation](/docs/dashboard/emails/embed-inline-images).

## Conclusion

Embedded images are a powerful tool for enhancing the visual appeal of your emails. By following best practices and understanding the potential issues, you can effectively use inline images to improve the user experience of your emails.

Let us know if you have any questions or feedback.
