Embedding Local Images for Email Clients

Greta is the lead developer on the desktop tool that German real-estate agents use to write property emails. An agent picks a listing, drags in three or four photos from their hard drive -- exterior, kitchen, view from the balcony -- writes a short personal note in German, and hits Send. The buyer opens the email in Outlook, sees the photos inline, and replies.

At least, that was the plan. Greta's first version composed the HTML and used data URIs to embed the photos. It worked beautifully in test. Then her agents started shipping it. Outlook on Windows downsized the inline images to thumbnails. Outlook on the web stripped some of them entirely. Buyers were getting half-broken property emails. The agents were furious.

The fix is that email clients have a long-standing standard for inline images -- CID-linked resources -- and they render those reliably. The WPF HTML Editor packages exactly that:

System.Net.Mail.MailMessage mail = editor.Content.GetEmailMessageWithLocalImagesEmbedded();

What comes back is a ready-to-send MailMessage with:

  • An HTML AlternateView whose body is the document, with every local <img src> rewritten to a cid: reference.
  • One LinkedResource per local image attached to that alternate view, each with the matching ContentId.
The German real-estate email composer built on WpfHtmlEditor with three property photos inserted inline, ready to send

Greta dropped her data-URI code and replaced it with the SMTP path her agents had been asking for since day one:

using System.Net;
using System.Net.Mail;
using System.Windows;

private void SendListingEmail_Click(object sender, RoutedEventArgs e)
{
    // 1. Build the MailMessage; local photos are embedded as CID resources
    MailMessage mail = editor.Content.GetEmailMessageWithLocalImagesEmbedded();

    // 2. Fill in the envelope
    mail.From    = new MailAddress("agent@immobilien.de", "Greta's Immobilien");
    mail.To.Add("interessent@example.de");
    mail.Subject = "Ihre Anfrage: Wohnung am Stadtpark";

    // 3. Send through the agency's SMTP server
    using (var smtp = new SmtpClient("smtp.immobilien.de", 587))
    {
        smtp.EnableSsl = true;
        smtp.Credentials = new NetworkCredential("agent@immobilien.de", "app-password");
        smtp.Send(mail);
    }

    MessageBox.Show("Email versendet. Die Bilder reisen mit.");
}

One nuance she found useful: the method only embeds <img> tags whose src is a local file path the editor can read. Photos already loaded from an http/https URL -- floor plans hosted on the agency's public site, for example -- are left as URL references. The recipient's mail client fetches those over the network the usual way. The two image sources coexist in the same email cleanly.

For one agent who wanted to log the email to the agency CRM before sending, Greta showed her how to enumerate the linked resources. They live under the alternate view:

var altView = (AlternateView)mail.AlternateViews[0];
foreach (LinkedResource lr in altView.LinkedResources)
{
    LogAttachment(lr.ContentId, lr.ContentType.MediaType, lr.ContentStream.Length);
}

The Outlook complaints stopped within the first week of the rollout. Greta picked up two more accounts on referral from the first agency.

The same property email opened in Outlook on Windows showing all three inline photos rendered at full size via CID linked resources
Last updated on May 12, 2026