Free Support Forum -

HTML contains inline images is missing while creating a document with mail merge


I am using mail merge to create a document. In the merge field I have to insert html content.
Using doc.MailMerge.FieldMergingCallback = new HandleMergeFieldInsertHtml(); i am able to insert html data. But inline image which is part of html is missing while conversion



Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.


Hi Tahir,

Thanks for your quick reply.

Please find the attached files for trouble shooting.

Also please find the sample html data which contains images.

<p>when does this matter updated<br><br></p><ol><li>fsdfsd</li><li>fgfdgf</li><li>fjfjsdfd<br><img alt="" src=“”><br><img alt="" src="/Utility/GetUploadedImage?Imagename=%2FKendoImages%2FImages%2FAlternatives_3.jpg"></li></ol> (21.4 KB)



We have tested the scenario using the latest version of Aspose.Words for .NET 19.3 and have not found the shared issue. Please use Aspose.Words for .NET 19.3. We have attached the output DOC file with this post for your kind reference. (9.1 KB)


I also used latest version of Aspose.Words for .NET 19.3 but didnt render image.
Could you please share the code for word conversion?


Also cannot install Aspose.Words 19.3 reference using Nuget. I am getting an error like
‘Aspose.Words’ already has a dependency defined for ‘SkiaSharp’… Could you please help me on that too?



Your document does not contain the Discussion mail merge field. We have modified your document and tested the scenario using the following code example. Please check the attached documents. (25.9 KB)

Document doc = new Document(MyDir + "MyTemplate.docx");
doc.MailMerge.FieldMergingCallback = new HandleMergeField();
doc.MailMerge.Execute(new string[] { "Discussion" }, new object[] { "" });
doc.Save(MyDir + "output.docx");

private class HandleMergeField : IFieldMergingCallback
    /// <summary>
    /// This is called when merge field is actually merged with data in the document.
    /// </summary>
    void IFieldMergingCallback.FieldMerging(FieldMergingArgs e)
        if (e.DocumentFieldName.Equals("Discussion"))
            DocumentBuilder builder = new DocumentBuilder(e.Document);
            builder.InsertHtml(File.ReadAllText(MyDir + "input.html"));

    void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)
        // Do nothing.

Please uninstall Aspose.Words and install it again through NuGet.
Installing Aspose.Words for .NET through NuGet


Hi Tahir,
Thanks for your reply. We found the issue is related with the image path. We used relative path as image source. eg: “< img src=”/Content/imagename.jpg" />". How can solve relative path issue?
Also we dont have any physical html file. html content is stored in the database which contains image relative path



You can use LoadOptions.BaseUri property to get or set the string that will be used to resolve relative URIs found in the document into absolute URIs when required.

This property is used to resolve relative URIs into absolute in the following cases:

  1. When loading an HTML document from a stream and the document contains images with relative URIs and does not have a base URI specified in the BASE HTML element.

  2. When saving a document to PDF and other formats, to retrieve images linked using relative URIs so the images can be saved into the output document.

    Aspose.Words.LoadOptions options = new Aspose.Words.LoadOptions();
    options.BaseUri = @“C:\temp”;

    Document doc = new Document(MyDir + “in.docx”, options);
    DocumentBuilder builder = new DocumentBuilder(doc);
    builder.InsertHtml(@"<img src=’/Content/image.png’ />");
    doc.Save(MyDir + “19.3.docx”);