(*//
标题:将网页保存为mht文件
说明:本地网页还未找到如何将图片打包,有知情者请发邮件告之
设计:Zswang
支持:wjhu111@21cn.com
日期:2004-01-05
//*)
uses ComObj;
function MhtText(mURL: string): string;
var
vCDOMessage: OleVariant;
begin
vCDOMessage := CreateOleObject('CDO.Message');
vCDOMessage.Configuration := CreateOleObject('CDO.Configuration');
try
vCDOMessage.CreateMHTMLBody(mURL);
Result := vCDOMessage.GetStream.ReadText;
except
raise;
end;
vCDOMessage := NULL;
end; { MhtText }
function MhtFile(mURL: string; mFileName: string): Boolean;
var
vCDOMessage: OleVariant;
begin
vCDOMessage := CreateOleObject('CDO.Message');
vCDOMessage.Configuration := CreateOleObject('CDO.Configuration');
Result := True;
try
vCDOMessage.CreateMHTMLBody(mURL);
vCDOMessage.GetStream.SaveToFile(mFileName, $00000002);
except
Result := False;
end;
vCDOMessage := NULL;
end; { MhtFile }
//Example
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
MhtFile('http://www.eping.net/fourm/index.asp', 'c:/temp/temp.mht');
end;