Problems with converting a .doc to html

Ok, let’s take it slowly.

There is a number of ways pictures can be stored in a Microsoft Word document:

  1. Picture actually stored inside the document.
  2. Picture linked ONLY. That is the picture is NOT stored in the document, only the link is stored.
  3. Pictured linked AND stored in the document.

As I understand you want to convert DOC to HTML and compose it all into an email and you want the receiving user to open the document and see all the pictures in it alright.

When Aspose.Words converts DOC to HTML it saves every image it finds in the document into individual file. At the moment, Aspose.Words does this for ALL images regardless of whether they are stored or linked to the document.

The easiest way I see you should compose an email is this:

  1. Create a temporary directory, use Guid.New for example to generate a unique name.
  2. Save DOC to HTML using Aspose.Words into the above directory. This will create one HTML file and as many image files as there are in the document.
  3. Create the email message from the HTML file.
  4. Enumerate through all files in the directory and add all image files as attachments to the email object (or whatever is the appropriate way of adding images to an HTML email).
  5. You have a ready email message, send it.
  6. Delete the temporary directory.

In your case, the document INCLUDES ONLY and does not store pictures in the document. For example, you have the following field:

INCLUDEPICTURE “C:\htmlemail_files\image002.jpg” \* MERGEFORMAT \d

Notice that:

  1. The image is included using absolute path.
  2. The image is not stored in the DOC file (the \d switch at the end).

This means that when you open this document in ANY program (be it Microsoft Word or Aspose.Words or any other program), you will ONLY be able to see the images if you have them in the C:\htmlemail_files folder.

Aspose.Words did not create that folder. I don’t know how you inserted that image into your document and why it is in that folder. I guess all your problems can be explained trying to work with images linked only and linked using absolute path. I hope my explanation was helpful.

By the way, you cannot easily see that INCLUDEPICTURE field in your case because the picture is floating (an ugly bit from MS Word this time). You cannot also see this picture in the Edit/Links dialog box for some reason. Therefore I had to switch the image into inline positioning mode, then using Alt+F9 I can see the field code.

Now, I don’t really think there is anything to fix in Aspose.Words.