Image CID not displaying correctly in HTML email with Mailjet

Hello Stack Overflow community,

I’m encountering an issue with embedding an image using CID (Content-ID) in an HTML email sent through Mailjet. Despite following the correct setup, the image does not display and instead, the alt text is shown.

Here is the simplified version of my code (with sensitive information removed):

using Mailjet.Client.Resources;
using Mailjet.Client.TransactionalEmails;
using Mailjet.Client;

using System;
using System.Linq;
using System.Threading.Tasks;

namespace TestSendEmailWithEmbeddedImage
{
    internal class Program
    {
        static string API_KEY = @"API_KEY_REDACTED";
        static string SecretKey = @"SECRET_KEY_REDACTED";

        static async Task Main(string[] args)
        {
            var senderEmail = "SENDER_EMAIL_REDACTED";
            var destEmail = "DEST_EMAIL_REDACTED";
            var senderName = "support";
        
            MailjetClient _client = new MailjetClient(API_KEY, SecretKey);
            var imageBase64 = "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAEklEQVR4nGP8z4APMOGVHbHSAEEsAROxCnMTAAAAAElFTkSuQmCC";
            var contentId = "ABCD"; // Unique identifier for the image

            var imageName = "image.png"; // Name of the image
            var body = $@"
                    <html>
                    <body>
                        <p>Voici une image :</p>
                        <img src=""cid:{contentId}"" alt=""image""/>
                    </body>
                    </html>";

            var attach = new Attachment(imageName, "image/png", imageBase64, contentId);
       
            var email = new TransactionalEmailBuilder()
                .WithFrom(new SendContact(senderEmail, senderName))
                .WithSubject("titre")
                .WithHtmlPart(body)
                .WithTo(new SendContact(destEmail))
                .WithAttachment(attach)
                .Build();

            var response = await _client.SendTransactionalEmailAsync(email);

            bool good = (response.Messages.First().Errors == null);
        }
    }
}

The email is sent successfully, but the image does not display. Here is the raw source of the received email:

From - Fri Jul 12 23:39:43 2024
X-Account-Key: account1
X-UIDL: 4A3663448AAF4AD4AB442D639AB2CEA5
X-Mozilla-Status: 0001
X-Mozilla-Status2: 10000000
X-Mozilla-Keys:                                                                                 
X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on winheb04
X-Spam-Flag: YES
X-Spam-Level: ****
X-Spam-Status: Yes, score=4.7 required=0.0 tests=FORGED_GMAIL_RCVD,
    FREEMAIL_FROM,HTML_IMAGE_ONLY_08,HTML_MESSAGE,MIME_HTML_ONLY,
    SPOOFED_FREEMAIL,SPOOFED_FREEMAIL_NO_RDNS,SPOOF_GMAIL_MID autolearn=no
    autolearn_force=no version=3.4.5
X-Spam-Report: 
    *  0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
    *      provider
    *      [HIDDEN]
    *  1.0 FORGED_GMAIL_RCVD 'From' gmail.com does not match 'Received'
    *      headers
    *  0.1 MIME_HTML_ONLY BODY: Message only has text/html MIME parts
    *  0.6 HTML_IMAGE_ONLY_08 BODY: HTML: images with 400-800 bytes of
    *      words
    *  0.0 HTML_MESSAGE BODY: HTML included in message
    *  1.5 SPOOFED_FREEMAIL_NO_RDNS From SPOOFED_FREEMAIL and no rDNS
    *  0.0 SPOOFED_FREEMAIL No description available.
    *  1.5 SPOOF_GMAIL_MID From Gmail but it doesn't seem to be...
Received: from o22.p25.mailjet.com ([185.189.236.22]) by winheb04.ikoula.com with
 MailEnable ESMTPS (version=TLS1_2 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384); Fri, 12 Jul 2024 23:39:37 +0200
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; q=dns/txt;
  d=bnc3.mailjet.com; [email protected]; s=mailjet2; x=1720827576;
  h=message-id:from:from:to:to:subject:subject:date:date:list-unsubscribe-post:list-unsubscribe:
  feedback-id:x-csa-complaints:x-mj-mid:x-report-abuse-to:mime-version:
  content-type;
  bh=zXJK7SKHFOl/sZ0wgwFut4B+r9oba3LnSSekwPp+BCE=;
  b=dCkZ5v6dF5hwVAB4faDY2OpiAKTP/lHlm4pNJCLk1gc8urQXD6McZTHmr
 NPFmcvPRpg2visYRYmUN82ZBmE1MGa6loHZwiE/QjU2cLHDnQY/88o2VYgHh
 xzMwqiEmI/aw6eDd4VE0zXE3LCwqgjFNcaPckUFnSQIZSOW/Hwx2vU=
Return-Path:
    <8611192a.BAAABcYgl5sAAAAAAAAAADrzFk8AAAACCP4AAAAAACZVxABmkaKY@a2512324.bnc3.mailjet.com>
Message-Id: <8611192a.BAAABcYgl5sAAAAAAAAAADrzFk8AAAACCP4AAAAAACZVxABmkaKY@mailjet.com>
From: support <[email protected]>
To: [email protected]
Subject: [4.7] titre
Date: Fri, 12 Jul 2024 21:39:36 +0000
List-Unsubscribe-Post: List-Unsubscribe=One-Click
List-Unsubscribe:
    <mailto:[email protected]>,
    <https://ssxz1.mjt.lu/unsub2?m=BAAABcYgl5sAAAAAAAAAADrzFk8AAAACCP4AAAAAACZVxABmkaKYykdiv6e9T1akWSrodGCj0QAjtK0&b=8611192a&e=a0ab8a57&x=G5WbUbsRpVkLljxWbgJSl6SzhpLmsUcB66oyX8WN774>
Feedback-Id: 42.2512324.2340013:MJ
X-CSA-Complaints: [email protected]
X-MJ-Mid:
    BAAABcYgl5sAAAAAAAAAADrzFk8AAAACCP4AAAAAACZVxABmkaKYykdiv6e9T1akWSrodGCj0QAjtK0
X-REPORT-ABUSE-TO: Message sent by Mailjet please report to
    [email protected] with a copy of the message
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-+zpCN5rjhXag2yK+qwRs"
Return-Path: <8611192a.BAAABcYgl5sAAAAAAAAAADrzFk8AAAACCP4AAAAAACZVxABmkaKY@a2512324.bnc3.mailjet.com>
X-Spam-Prev-Subject: titre

--=-+zpCN5rjhXag2yK+qwRs
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html>
<body>
    <p>Voici une image :</p>
    <img src="cid:ABCD" alt="image"/>
</body>
</html>

--=-+zpCN5rjhXag2yK+qwRs
Content-Type: image/png; charset=utf-8; name=image.png
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename=image.png
Content-Id: <ABCD>

iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAEklEQVR4nGP8z4APMOGVHbHSAEEs
AROxCnMTAAAAAElFTkSuQmCC

--=-+zpCN5rjhXag2yK+qwRs--

Here is a screenshot showing the result where the image does not display, and the alt text is shown instead:

Note that the image, a red square, is visible only as an attachement file (image.png)

I’ve checked the CID format, ensured it matches in the HTML and the attachment, but the image still doesn’t display. I suspect there might be something I’m missing or a specific issue with how Mailjet handles embedded images.

I appreciate any insights or suggestions on how to resolve this issue. Thank you!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật