Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a html file with some images linked which are in another folder.Now using CDO dll I have created mht file from that html.Problem is,the file can not be opened in word,it can only be opened in IE.

But when i open the created mht file in IE and then save the page from page->save as ->.mht option then the mht file can be opened in word.

So what IE adds extra to that file so that it can be opened in word?

My code is----------------------------------------------------------------------------------
CDO.Message msg = new CDO.MessageClass();
CDO.Configuration cfg = new CDO.ConfigurationClass();
msg.Configuration = cfg;


msg.CreateMHTMLBody("file://"+myhtmlfilepath, CDO.CdoMHTMLFlags.cdoSuppressAll,"","");

msg.GetStream().SaveToFile(mylocation+"\\test.mht", ADODB.SaveOptionsEnum.adSaveCreateOverWrite);
Posted

1 solution

the problem is in the page which you are trying to convert, there are some resources such as stylesheet or js files and etc being used while you don't add these resources to your mht file so that's why the file cannot be opened by Microsoft World.

there is very good sample code in the following URL that could be helpful for you

http://code.msdn.microsoft.com/windowsdesktop/Creating-a-MHTML-MIME-HTML-61cf5dd1[^]

If you use Word 2013 it says which resources are missed
 
Share this answer
 
v2
Comments
souvikcode 20-Jun-14 9:47am    
I have no js or css file,just have images.In IE it is opening perfectly.If the HTML file can be converted to word or something portable file,that also will be ok.If I give user the HTML file then I have to give the file itself and the folder containing images.So I need only one file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900