Should SaveFormat MHTML include cid in inline image SRC

The use case is Word Template -> SaveFormat.MHTML to EMAIL
The MHTML “mime” format converts very nicely.

Being forced by Microsoft oAuth changes to switch from .NET Mail.Message to ones that support oAuth.

The inline image are now broken, and the email client provider says it is because you don’t have cid: in your inline image tags.

Effectively

<img src=3D"image.001.jpeg" width=3D"225" height=3D"110" alt=3D"" />

should be

<img src=3D"cid:image.001.jpeg" width=3D"225" height=3D"110" alt=3D"" />

Sample code below requires a simple word template with an embedded image (like a logo):

static void Main(string[] args)
{
    Aspose.Words.License wordLicense = new License();
    wordLicense.SetLicense("Aspose.Total.lic");

    Aspose.Words.Document wd = new Aspose.Words.Document("Template.docx");
    wd.Save("f:\\tmhtml\\wd.mhtml", SaveFormat.Mhtml);
}

@StanYork You should enable HtmlSaveOptions.ExportCidUrlsForMhtmlResources property to get the desired output:

Document doc = new Document(@"C:\Temp\in.docx");

HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.Mhtml);
options.ExportCidUrlsForMhtmlResources = true;

doc.Save(@"C:\Temp\out.mhtml", options);

Thanks for the quick response - this has done the trick and works much more cleanly in Outlook, Edge, GMail…

Don’t you think maybe you should be changing the default?
(BTW: if you use your Outlook MSG to EML conversion…it uses CID prefixes :slight_smile: )

@StanYork Thank you for your suggestion. In this case, Aspose.Words mimics MS Word behavior, which does not write cid by default. So currently it is not likely we will change the default value of ExportCidUrlsForMhtmlResources property.