GemBox Support Forum

Only 'IPM.Note' messages are supported error

Hello, we are using Gembox to convert mails to pdfs, but for an unknown reason this email fails.
This is the Email File-Upload.net - BesprechungumdieInventurplanungzumachen.msg

We are using the latest version and I tried it too, with the online page example, where I too, get an error.
It would be great if you could say whats wrong and how we can fix it.

using System.Linq;
using System.Text.RegularExpressions;
using GemBox.Document;
using GemBox.Email;
using GemBox.Email.Mime;

class Program
    static void Main()
        // If using Professional version, put your GemBox.Email serial key below.
        // If using Professional version, put your GemBox.Document serial key below.

        // Load an email file.
        MailMessage message = MailMessage.Load("Attachment.msg");

        // Create a new document.
        DocumentModel document = new DocumentModel();

        // Import the email's content to the document.
        LoadHeaders(message, document);
        LoadBody(message, document);
        LoadAttachments(message.Attachments, document);

        // Save the document as PDF.

    static void LoadHeaders(MailMessage message, DocumentModel document)
        // Create HTML content from the email headers.
        var htmlHeaders = $@"
              * {{ font-size: 12px; font-family: Calibri; }}
              th {{ text-align: left; padding-right: 24px; }}
              <tr><th>From:</th><td>{message.From[0].ToString().Replace("<", "&lt;").Replace(">", "&gt;")}</td></tr>
              <tr><th>Sent:</th><td>{message.Date:dddd, d MMM yyyy}</td></tr>
              <tr><th>To:</th><td>{message.To[0].ToString().Replace("<", "&lt;").Replace(">", "&gt;")}</td></tr>

        // Load the HTML headers to the document.
        document.Content.End.LoadText(htmlHeaders, LoadOptions.HtmlDefault);

    static void LoadBody(MailMessage message, DocumentModel document)
        if (!string.IsNullOrEmpty(message.BodyHtml))
            // Load the HTML body to the document.
                ReplaceEmbeddedImages(message.BodyHtml, message.Attachments),
            // Load the TXT body to the document.

    // Replace attached CID images to inlined DATA urls.
    static string ReplaceEmbeddedImages(string htmlBody, AttachmentCollection attachments)
        var srcPattern =
            "(?<=<img.+?src=[\"'])" +
            "(.+?)" +

        // Iterate through the "src" attributes from HTML images in reverse order.
        foreach (var match in Regex.Matches(htmlBody, srcPattern, RegexOptions.IgnoreCase).Cast<Match>().Reverse())
            var imageId = match.Value.Replace("cid:", "");
            Attachment attachment = attachments.FirstOrDefault(a => a.ContentId == imageId);

            if (attachment != null)
                // Create inlined image data. E.g. "data:image/png;base64,AABBCC..."
                ContentEntity entity = attachment.MimeEntity;
                var embeddedImage = entity.Charset.GetString(entity.Content);
                var embeddedSrc = $"data:{entity.ContentType};{entity.TransferEncoding},{embeddedImage}";

                // Replace the "src" attribute with the inlined image.
                htmlBody = $"{htmlBody.Substring(0, match.Index)}{embeddedSrc}{htmlBody.Substring(match.Index + match.Length)}";

        return htmlBody;

    static void LoadAttachments(AttachmentCollection attachments, DocumentModel document)
        var htmlSubtitle = "<hr><p style='font: bold 12px Calibri;'>Attachments:</p>";
        document.Content.End.LoadText(htmlSubtitle, LoadOptions.HtmlDefault);

        foreach (Attachment attachment in attachments.Where(
            a => a.DispositionType == ContentDispositionType.Attachment &&
                 a.MimeEntity.ContentType.TopLevelType == "image"))
                new Paragraph(document, new Picture(document, attachment.Data)).Content);

Just the normal code.

Greetings Brian

Hello, I also had another issue with this email:

Take ages to load, I narrowed it down to this code of line from your example:

    ReplaceEmbeddedImages(message.BodyHtml, message.Attachments),

What could I do to get it faster?

I found out that the Mail contains an image Link that leads to a website and then downloads it there and replaces the image with that. How can I forbid to do that?

The saving and loading text also takes very long for those emails, very strange.
Greetings Brian

Hi Brian,

Regarding the failed email loading, the problem with that MSG file is that it is not an email.
Try opening it in Microsoft Outlook, you’ll notice that the Meeting is opened.

Regarding the slow HTML loading, the problem is with this this image URL:

It takes +30 seconds to load it, for example, please check this:

var watch = Stopwatch.StartNew();

var options = new HtmlLoadOptions();
options.ResourceLoading += (sender, e) =>
    Console.WriteLine($"Loading: {e.Uri}");

string html = ReplaceEmbeddedImages(message.BodyHtml, message.Attachments);
document.Content.End.LoadText(html, options);

Console.WriteLine($"Finished: {watch.Elapsed}");

This is probably a tracking pixel in the email’s message.

I hope this helps.