从c#转换的mht文件的问题 [英] problem with converted mht file from c#

查看:255
本文介绍了从c#转换的mht文件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html文件,其中一些图像链接在另一个文件夹中。现在使用CDO dll我已经从那个html.Problem创建了mht文件,该文件无法在word中打开,它只能在IE中打开。



但是当我在IE中打开创建的mht文件然后从页面保存页面 - >保存为 - > .mht选项然后mht文件可以用word打开。



那么IE为该文件增加了额外的内容,以便可以用文字打开它?



我的代码是------------------------------------------- ---------------------------------------

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);

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);

推荐答案

问题出在您要转换的页面中,有一些资源如此当你没有将这些资源添加到mht文件时使用样式表或js文件等等,这就是为什么微软世界无法打开文件的原因。


那里是以下URL中非常好的示例代码,可能对您有所帮助



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



如果您使用Word 2013,它会说错过了哪些资源
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


这篇关于从c#转换的mht文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆