Nomsa Guide
  • 👋About Nomsa
  • Campaign Guide - General
    • 🚀How to send a campaign?
  • Campaign Guide - Email
    • 📧Email Campaigns - Basics
      • Scheduled Sending
      • Bounced Emails and Halted Campaigns
      • Email Statistics
      • Formatting your Message Template
      • Variable Fields
      • Unique URL Link per Recipient
      • Pasting Content from Microsoft Word
      • Manage your Unsubscriptions
      • Understanding Unsubscriptions
    • 🔐Sending Password-Protected Emails
      • Tutorial
  • Campaign Guide - SMS
    • 📲SMS Campaigns - Basics
    • SMS Onboarding Overview
      • How do I send SMS
  • Campaign Guide - Telegram
    • 🤖Telegram Campaigns - Basics
      • Add Telegram Bot Token in Nomsa
      • Instructions for Recipient Onboarding
      • Use the Bot in the Campaign
      • Telegram Formatting
      • Telegram Bot Statistics
  • Api Guide
    • 📖Overview
      • API Response Formats
      • Bearer Authentication
      • Generate your API Key
      • Rotate your API Key
    • 📨Programmatic Email API
      • Custom From Address
      • Tracking Email Status
      • Send Email API
        • From Name and From Address
        • CC and BCC
        • Recipient Blacklist
        • Email Tagging and Classification
        • Email Body
          • Embedding Images
            • Linked Images
            • Content-ID Images
        • Attachments
        • Rate Limit
      • Get Email by ID API
      • List Emails API
    • 📬Programmatic SMS API
Powered by GitBook
On this page
  • How It Works
  • Not Recommended for Same Images Across Multiple Emails
  • Unique Image for Each Email
  • Using our API
  • Example API Request
  1. Api Guide
  2. Programmatic Email API
  3. Send Email API
  4. Email Body
  5. Embedding Images

Content-ID Images

How It Works

Content-ID images work by attaching the image to the email you send and then using standard HTML image tags that reference that image to eventually embed it in the email when the user opens it.

Not Recommended for Same Images Across Multiple Emails

If you are using the same set of images across multiple emails, we advise you to look into using linked images for the following reasons:

  • As the same images are being used, attaching the same image to each email is inefficient and bad for the environment

  • Content-ID images are larger in size as the image is attached to the email. This slows down your API calls and increases costs.

For more information, see here.

Unique Image for Each Email

Content-ID images can be used for embedding dynamically generated images in your emails. This is a reasonable alternative for agencies that are unable to host images on the Internet.

Using our API

To support content-ID images, we have parsed each attachment to add a cid field based on the order in which they are attached. This allows the first attachment to be referenced by cid:0, the second by cid:1, and so on. You can then use these cid values in your HTML image tags.

Note that the cid values are zero-indexed, i.e. the first attachment is cid:0, the second is cid:1, and so on. This cid field is added for all files, including non-image files.

As content-ID images work by attaching emails, you will need to fulfill the requirements

Example API Request

The following example shows how you can use the cid field to embed images in your email.

curl --location 'https://api.nomsa.gov.kh/v1/transactional/email/send' \
--header 'Authorization: Bearer {{apikey}}' \
--form 'recipient="recipient@gmail.com"' \
--form 'from="NomsaSupportTeam <nomsa@dgc.gov.kh>"' \
--form 'subject="test cid"' \
--form 'body="Hello there.
<br>
<img src=\"cid:0\">
<br>
<img src=\"cid:1\">
<br>

"' \
--form 'attachments=@"/path/to/attachment/dgc-logo.png"' \
--form 'attachments=@"/path/to/attachment/mptc-logo.png"' \

The resulting email:

PreviousLinked ImagesNextAttachments

Last updated 1 year ago

📨