请问VB中如何用代码创建单个文件网页(*.mht)
请问VB中如何用代码在指定路径下创建单个文件网页(*.mht),如(D:\File\123.mht).然后插入内容和图片,用IE进行浏览,能看到所插入的内容及图片。
[解决办法]
基本格式是这样:
原理就是类似于EMAIL邮件编码,用BASE64等编码方式
From: <由 Microsoft Internet Explorer 5 保存>Subject: =?gb2312?B?dmxvb2t1cLC0MsHQsunV0l+w2bbI1qq1wA==?=Date: Fri, 16 Sep 2011 13:05:35 +0800MIME-Version: 1.0Content-Type: multipart/related; type="multipart/alternative"; boundary="----=_NextPart_000_0000_01CC7471.52D02180"X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5512This is a multi-part message in MIME format.------=_NextPart_000_0000_01CC7471.52D02180Content-Type: image/gifContent-Transfer-Encoding: base64Content-Location: http://img.baidu.com/img/logo-zhidao.gif------=_NextPart_000_0000_01CC7471.52D02180Content-Type: image/gifContent-Transfer-Encoding: base64Content-Location: http://img.baidu.com/img/iknow/avarta/48/r6s1g1.gif
[解决办法]
'创建指定路径下的网页
IsFile.CreateTextFile FilePath
'得到指定路径下的网页
Set fil = IsFile.GetFile(FilePath)
'对指定路径下进行操作类型。ForWriting:写入
Set ts = fil.OpenAsTextStream(ForWriting)
'将指定内容写入到网页中
ts.Write FileText