Free Support Forum -

<img.../> tag in html output

Hello there,

I am inserting some images during mail merge process in Aspose Document and
finally saving it in HTML format to send as an email attachment.

Because Html output file and its images are saved on some folder on server,
when the email recipient opens the attachment, the images are not available as they are opened from the client machine and not from the server.

I want to replace value of img ‘src’ attribute value so that it changes the image reference to location on server.

Could you please guide me how can I access <img…/> tags in html document.

Thank you!

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> Hi

Thanks for your request. Please see the following link to learn how to convert a Document to MHTML and Email:

Also, you can download example there.

Best regards,

Thanks Alexey!

We have recently bought license for Aspose.Words,
should we also buy license for Aspose.Network in addition?

Is there any way I can edit and change the path in <img…/> tag in html that’s going as email attachement?

Please guide.

Hi Nutan,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Aspose.Words and Aspsoe.Network are different products and requires different licenses. So if you would like to use Aspose.Network, you should buy license for it.

You can easily find tags in your HTML using regular expressions. Also, I think, the example provided in the following thread could be useful for you:

Best regards,

Thanks Alexey,

As, the client requirement is both
- Sending html document as an attachment as well as
- Attaching html as an email body

(both may contain images), So, we might need to buy Aspose.Network.

However, I was just trying to locate <img…/> tags in html output document, but cudn’t see.

Here is how I was trying:
//Create Document object
Document objDocument = new Document(htmlFilePath, LoadFormat.Html, “”);

Now when I see objDocument.ToTxt(), it doesn’t show any <img…/> tags.

How can I locate these <img…/> tags?

Thank you!

Hi Nutan,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. You can use the following code to convert document to HTML string:

public string ConvertDocumentToHtml(Document doc)


string html = string.Empty;

// Save docuemnt to MemoryStream in Hml format

using (MemoryStream htmlStream = new MemoryStream())


doc.Save(htmlStream, SaveFormat.Html);

// Get Html string

html = Encoding.UTF8.GetString(htmlStream.GetBuffer(), 0, (int)htmlStream.Length);


// There could be BOM at the beggining of the string.

// We should remove it from the string.

while (html[0]!='<')

html = html.Substring(1);

return html;


Hope this helps.

Best regards.